dvas0004 / NerdNotes

A collection of notes: things I'd like to remember while reading technical articles, technical questions I couldn't answer, and so on.
12 stars 0 forks source link

useRef makes for uncontrolled components #98

Open dvas0004 opened 5 years ago

dvas0004 commented 5 years ago

Typically we use hooks like useState which are controlled in that they store data within state. Whenever data stored in state changes, the component is re-rendered.

In order to avoid re-rendering, we cannot store data in state - this is referred to as uncontrolled. the useRef hook allows us to do this by storing data separately from the state and avoiding re-renders

dvas0004 commented 5 years ago

https://www.codebeast.dev/usestate-vs-useref-re-render-or-not/