-
Notifications
You must be signed in to change notification settings - Fork 49
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
React useState doesn't update correctly #99
Comments
This is the code I am using. Using Mantine library for UI. I originally had the data in a parent component and passed the state and state updater to this one, but thought that was my issue. So now I am saving local state and not even worrying about the parent state.
|
I also tried stripping this back to just regular |
I had a similar issue which I've struggled with for a few hours. Not entirely sure if it's the same, and also not entirely sure whether it was a bug in the library, or in the way React handles arrays/children, or the way browsers keep track of input elements. In my case, I had a form, to which the user can add new input elements (textareas) and move them around. I was using controlled components. On creation, In my case, the solution was to store the value of a newly created textarea as an empty string in state. Seeing as your example used Edit: React 18.2.0, in both Chrome 120 and Firefox 114 |
Unsure if I am doing something wrong here, but I have an issue where my state isn't being updated in the
onChange
hook.I get a weird effect where after dragging and dropping, the list looks like it did prior to the drag & drop.
If I try to drag the list item from where I left it, it transforms into the old element.
See the example above.
I tried searching for a similar issue in the issues here, and noticed someone else implemented a
setTimeout
which actually fixed it, but then created a flash of missing content in my modal which is not desirable...Am I doing something wrong here?
The text was updated successfully, but these errors were encountered: