Re:Thinking in React Hooks
by steve_taylor on Saturday December 14, 2019 @03:55AM
(#21788530)
I had no idea the setter can take a function instead of a value. It makes perfect sense, because setState has the same feature. TIL.
[ Parent
| on HN ]
FWIW, it's documented in the API reference:
https://reactjs.org/docs/hooks-reference.html#functional-upd...