-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't read the newest props in Sortable problem #1885
Comments
I am also experiencing the same problem. I am wondering if there is a temporary workaround for this? |
My way is to create a new state variable and set it in |
The react bindings use the sortable events to manipulate the DOM and update state, to which i see you're updating the state of your application. Try You'd have to provide a working example to get additional help, using a code sandbox or something similar. |
I'm experiencing an issue like this except with onAdd and onRemove with useEffect, i pass in my dependency to useEffect and onAdd gets the updates but onRemove does not. The result is when I add any items to a list the state is updated but when i remove them my state is reset to it's original value. |
I'm using sortablejs in React since I need the handle and nested drag-and-drop list.
Problem: I can't read the newest props when the drag action ends.
Description: This page is for editing purpose. I have a nested 3 level drag and drop list with textarea. like this
I only have an "allItems" state in my parent component and every text change will modify this state and trigger the rerender.
When I finish dragging, the list's order will change, but all the changes I did in the textarea are gone.
I tried to print out the "allItems" in different places, I found out that in store.set, onEnd, onUpdate, and onChange, the data of "allItems" is the initial value, not the newest one.
So I assume that somehow there's a state in my sortable variable and it is not updated.
But I thought that I change the state, trigger the rerender, and my useEffect listen to the "allItems" passed in from parent and create the sortable again, so it should have the newest value?
How can I solve this problem?
Thanks in advance.
Code:
The text was updated successfully, but these errors were encountered: