The Ugliest Pattern In React

Sebastian Carlos
3 min readJan 7, 2023

Brace yourselves. Out of all the nastiness in the React world, nothing comes close to this.

Usually, you will update state in event handlers. However, in rare cases, you might want to adjust state in response to rendering — for example, you might want to change a state variable when a prop changes.

Granted. In most cases, you don’t need this:

  • If the value you…

--

--