react-draggable
react-draggable copied to clipboard
How to save the position of react-draggable component after reloading(refreshing page)?
I have created one form in which inputs elements drag according user needs. now i want to save the position of inputs fields and after refreshing the page i want to save the previous position of input fields(before refreshing) is it possible. if possible then how?
I would save the current position when dragging stops (onStop) and then use it as a defaultPosition for next mount.
defaultPosition={state.defaultPosition}
onStop={(e, data) => {
saveState({ defaultPosition: { x: data.x, y: data.y } });
}}
Hope this helps.
@Varad25 solution worked great. Just saved default position for each element to the localstorage and it worked like a charm!
@Varad25 it doesn't work properly. It always mixup things.