Don't Overuse State In React - Sometimes You Can Useref

[!INFO]-
topic: 🧩 React
links: Pros and cons of React
source: Site Unreachable
tags: #permanent-noteΒ #published

Last Modified: =dateformat(this.file.mtime, "MMM. dd, yyyy - HH:mm")


Don't use state for every variable that comes up.

For example, if you have a login form with user and password, you should not write those variables into the state if you actually don't care if they update. If you update the state onChange of every letter that is written, you cause unwanted re-renders. Use useRef instead. Mapping the reference handles the update of the input and when you send the request, you just access the value via emailRef.current.value.