4 ms·
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.
by steve_taylor 7y ago
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.
- acemarke 7y agoFWIW, it's documented in the API reference: https://reactjs.org/docs/hooks-reference.html#functional-updates https://reactjs.org/docs/hooks-reference.html#functional-upd...