DEV Community

Discussion on: What are your opinions on local state vs global state in React?

Collapse
 
ttutisani profile image
Tengiz Tutisani

Local state always! Global state is an anti-pattern.

Preference for the global state originates from the unawareness of the problems related to global, shared variables. Software development has already learned the lesson and switched to encapsulation, local variables, etc. But I guess not everybody read the right books, or they think the front-end is a different story.

History has proved that the front-end and javascript are going through the exact same path as all other programming languages already did. Therefore, it's only a matter of time that the global state becomes an official anti-pattern in React, too.

BTW, I'm glad to find out that it's not only me who is puzzled with this all global state direction! Thanks for this discussion!