[Question] How do I get the next state value?
See original GitHub issueconst [value, setValue] = useAtom(atom(1))
useEffect(() => {
...
setValue(3)
console.log(value) // === 1
// how do I now get the latest value of the atom?
})
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (8 by maintainers)
Top Results From Across the Web
How to access the latest state value in the functional ...
React state updates are asynchronous, i.e. queued up for the next render, so the log is displaying the state value from the current...
Read more >Introduction to State Table, State Diagram & State Equation
Digital Electronics: Introduction to State Table, State Diagram & State EquationContribute: http://www.nesoacademy.org/donateWebsite ...
Read more >Solved Question 3 1 pts Enter the value of next state (Q+)
Question : Question 3 1 pts Enter the value of next state (Q+) when S=0, R =0 and present state (g)= 1 for...
Read more >Why is the state-action value function used more than the state ...
1 Answer 1 · 2. It may be also worth emphasizing that, if you're using a table, the state-action value function will be...
Read more >Hooks FAQ - React
This page answers some of the frequently asked questions about Hooks. Adoption Strategy. Which versions of React ... How to get the previous...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s good to hear. Please note the use case of this util is not thoroughly tested / considered.
There is a hypothetical case it may not work as expected in Concurrent Mode in the future. (It’s a sort of edge case, if there’s a derived read atom (both sync and async), and if stateCallback is invoked before react updates the state in its scheduler, it would return an old value.) Technically impossible, but there might be a workaround on user end.
If anyone get an issue, please open a new issue. Closing this as resolved.
Closing this as stale. We can reopen with a repro, or open a new one.