Timeline for answer to The useState set method is not reflecting a change immediately by Tunn
Current License: CC BY-SA 4.0
Post Revisions
11 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 17, 2025 at 1:41 | history | edited | Peter Mortensen | CC BY-SA 4.0 |
Eliminated the sentence fragment.
|
| Jun 1, 2022 at 15:14 | comment | added | Tunn | Not disagreeing with you. My point is that no one has given a concrete example or explanation on what the warnings or drawbacks are here, or a link that shows how this is incongruent with the design. I'm fine with the downvotes, but I don't find a comment like "there are much better ways" to be particularly insightful even though it may be perfectly valid, just show it or link to something :) | |
| May 31, 2022 at 19:26 | comment | added | ggorlen | "A design theory level" seems to be a perfectly valid reason to criticize something. Just because something works or is possible doesn't make it worth putting out there. Folks might actually use this pattern in spite of the warnings. There are much better ways to deal with the "problem" (it's not exactly a problem to begin with, just seems like that to folks who are unused to asynchronous code). | |
| May 16, 2022 at 7:22 | history | edited | E_net4 | CC BY-SA 4.0 |
remove meta-commentary
|
| May 15, 2022 at 13:00 | history | edited | Tunn | CC BY-SA 4.0 |
Simplify
|
| Apr 8, 2022 at 19:58 | history | edited | Tunn | CC BY-SA 4.0 |
deleted 29 characters in body
|
| Mar 25, 2022 at 14:30 | comment | added | Tunn | Again, not saying this is the best way or to use it, just saying it works. Would be more useful to say what the issues would be in using it with a reproducible example as opposed to disregarding it from a design theory level | |
| Mar 21, 2022 at 20:13 | comment | added | Jamie Nicholl-Shelley | Using count and or callbacks hinders the design method behind usestate itself I'm afraid. | |
| Mar 15, 2022 at 9:47 | comment | added | Tunn |
I am in favor of emphasizing pure functions, but that link isn't specific to the useState callback (there are use cases for not using a pure function as the callback). Also, although this isn't "pure", it doesn't actually change any state either. I'm not saying this is the best way (I don't use it), just that it provides an alternative solution to the OPs question
|
|
| Mar 14, 2022 at 22:18 | comment | added | Emile Bergeron |
setState setter callback should be pure.
|
|
| Dec 18, 2021 at 17:31 | history | answered | Tunn | CC BY-SA 4.0 |