DEV Community

Discussion on: Autosaving with React Hooks

Collapse
 
ehellman profile image
Erik Hellman

You should probably store the "lastText" value in a Ref instead since doing useState re-renders the component. If you update lastText and text at the same time you will get 2 re-renders every time you really just wanted one.

Collapse
 
bernardbaker profile image
Bernard Baker

Could you explain the theory behind using a Ref in this instance?

Collapse
 
wolverineks profile image
Kevin Sullivan

Doesn't React batch updates?