Cleaning up setter function that is a function
So I need to set my state to this:
() => {}
. However, if you supply () => {}
to react in a setter, like so: setState(() => {})
it will instead return an empty object, since React uses that syntax to use the previous state.
Is there a better way to do this than this: setState(() => () => {})
?2 Replies