DEV Community

Discussion on: How to useRef to fix React performance issues

Collapse
 
dispix profile image
Octave Raimbault

Shouldn't you be able to achieve the same design with useState instead if you use 2 providers (1 for the data, which changes often, and 1 for the functions that shouldn't update)?

This seems a better practice than using ref which brings us back to the issue of the classes era with mutable values. Whereas splitting in 2 contexts leverage closures to achieve the same thing.