Skip to content
public-library›Rules›React›Keep values that do not affect rendering in refs

Keep values that do not affect rendering in refs

Store a value in useRef when it changes often and the rendered output does not depend on it. Keep a value in state when the UI displays it or derives output from it.

In the full rule