I m working on a simple react UI which uses React beautiful Drag and Drag Library for Dragging and Dropping
The Items however use an iframe with a third party application widget in.
When I drag these they re-render the entire iframe which I don’t want to happen, is there a way to stop this?
See example of this happening.
https://codesandbox.io/p/sandbox/react-beautiful-dnd-sample-forked-49cc7x?file=%2Fsrc%2FApp.tsx
How can we prevent from reloading ?
2
Answers
I think I can give you some suggestions that could help:
useMemo
or by moving the iframe outside the component that is frequently experiencing a state change.You can now use the
IframeComponent
like<IframeComponent src="https://example.com" />
key
prop: You can use a fixedkey
prop on the iframe.Let me know if this helps.
Just use it in useEffect to prevent side effects.
Before:
After: