Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React: Can the global state of the stores be manipulated in the browser?

A fun curiosity as I build my React application:

I notice how in the browser we can play with the client-code and/or resources. (e.g change css, change html, change a js variable).

Does that mean we can also manipulate the global state of the stores from the browser?

For example, if are doing client-side routing(all client-code is on the browser) and we are checking the store data to see if a user is logged in order to allow routing - couldn't we(or anyone for that matter) just manipulate the store state to override the required login and just walk around the application anyways?

I realize that example can be trivialized in many ways - but the main question is if the global state of the client application code can be played with to trigger different renderings of components while in the browser or even render completely different parts of the component state tree for that matter.

Note: Forgive any signs of major ignorance this might expose.haha. I'm just not sure and I think it would be interesting to know for many reasons both from a development and UX standpoint.

like image 847
Nick Pineda Avatar asked Feb 24 '16 04:02

Nick Pineda


People also ask

How do you manage state globally in React?

To manage your global state, reach for tried and tested third-party libraries like Zustand, Jotai, and Recoil. Redux is also great, but make sure that you get started using Redux Toolkit.

Can Redux state be manipulated?

Yes it can be easily manipulated.


1 Answers

Yes, with React/Redux Dev Tools user can do anything with data in the store. So you should never store any sensetive data on frontend, and validate every user request on server-side.

like image 196
xCrZx Avatar answered Sep 24 '22 04:09

xCrZx