You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a set of tags, which include locationX and locationY values. When my component renders, they appear in the right place. However, I want to be able to drag these to a new location, and then save that location.
For reference, here's setCount: const [count, setCount] = useState(0);
The parent view is simply a View with flex: 1
Eventually I'd like to replace this with a hook that updates the most recent location. Any kind of re-render seems to cause the jumping issue, whether it's through Redux props, hooks, or setState.
The text was updated successfully, but these errors were encountered:
I had the same problem, then I started to mess with his example and created a normal variable to store the position of the draggable. Probably is not the best solution, and I need to work on my project to test if this works there.
var initialY = initialPosition; // any value you want
...
<Draggable
y={initialY}
onDrag={(event, gestureState) => initialY = gestureState.moveY}
/* other props you want */
/>
I also made some progress since posting this issue yesterday. I'm storing the X and Y coordinates for each view in Firebase, and when the component renders I use those as the initial X and Y props. I also made a copy of the item in the local component state using hooks.
Then, rather than updating initial props on drag, I just update the new copy in local state. Once the user chooses to save their changes, I send the local state copy back to Firebase. I think this will work, but needs further investigation.
I have a set of tags, which include
locationX
andlocationY
values. When my component renders, they appear in the right place. However, I want to be able to drag these to a new location, and then save that location.Here is my code:
For reference, here's
setCount
:const [count, setCount] = useState(0);
The parent view is simply a
View
withflex: 1
Eventually I'd like to replace this with a hook that updates the most recent location. Any kind of re-render seems to cause the jumping issue, whether it's through Redux props, hooks, or setState.
The text was updated successfully, but these errors were encountered: