In this post, we will see how to resolve How to judge by the value of useState updated in useEffect from dispatch and payload in Redux
Question:
Sorry the title is not clear.I use React and Redux-toolkit. I immediately referenced the updated value in the useState set function, but I get the value before the update. I know that useState updates are not performed immediately.
1.What we want to do I want to immediately refer to the updated value of useState in the event.
2.summary I want to reacquire the list in the event and make a judgment based on the number of lists (multipleList.length) after reacquisition.
3.Code
I created a new array within onChangeAddr3 and so on, but could not get the updated list.
Thank you.
Add Code (Code in a separate file. useSelector from Store)
Best Answer:
I don’t know if this is correct, but it has resolved itself.this took the expected value.
If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com