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!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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!