DEV Community

loading...

Discussion on: react-use-localstorage

Collapse
andreasklinger profile image
Andreas Klinger ✌️️

why do you also save into state? for re-renders?

Collapse
dance2die profile image
Sung M. Kim Author • Edited

That's a great observation, Andreas.

It's to turn <input /> into a controlled component, which makes input's state to be controlled by React (one source of truth for state)

Forem Open with the Forem app