You're 100% right, there's no need to mess with refs in this case. I totally forgot about the functional state update. I'm going to add a note about that. Thank you!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You can provide a callback for
useState
that accepts the current state.setIsToggled(state => !state)
I don't get why you have to use refs for this.
You're 100% right, there's no need to mess with refs in this case. I totally forgot about the functional state update. I'm going to add a note about that. Thank you!