Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is data stored in react? [closed]

I am not a react developer (I know basic js), however there is a web game (that runs on react) that I have been trying to look inside of and see if I can edit the stored values for a bit of fun. I checked the network tab and it seems to be all client based. I ran a js script to get all the objects, but all I could find was static data about the game, nothing storing my score or anything useful.

How is storage handled in react? How would I find/change data like my score?

like image 932
William Ehrenberg Avatar asked Apr 15 '20 17:04

William Ehrenberg


People also ask

Where does react store its data?

In terms of React, nowhere, since react does not store any data Redux: stores data in redux store, which internally is js object (s) stored in the memory (RAM). Depending on what level of detail you want to go into, take your pick. ridiculous interview question btw.

What is local storage in React Native?

Introduction to React Native Local Storage. Every major app needs local storage to store some information of the user locally even after getting offline, it helps in gathering each and every information once again when you login and provide the user a seamless experience. It also supports local storage for this purpose.

How do I clear local storage in react JS?

localStorage.clear(); Whereas the first argument is the key to store/retrieve the data, the second argument -- when storing the data -- is the actual data. Once you close the browser and open the JavaScript application again, you will find the data still in the local storage. Local Storage in React

How to add form data in react local storage using bootstrap?

Get into the React local storage project by using the following command. Next, Import bootstrap.min.css in src/App.js file from node_modules folder: Create src > components folder and create a component file for storing form data in local storage. Name this file form-data-component.js and paste the following code in it.


1 Answers

there are several places that we might store data in a react application;

  • components states ( explore it via react dev tools )
  • global states like Redux (redux dev tools), Mobx or Contex API
  • localStorage / sessionStorage ( explore it under application tab in inspector )
  • cookies( used in server communication ), available via document.cookie
  • local variables outside the components scope (kinda like global scope variables on javascript but not exactly); which is definitely not recommended but some people might do that. (the only way to explore them is by putting break points inside the source tab in the inspector; which is really hard to trace and investigate btw)
like image 120
Mhmdrz_A Avatar answered Oct 30 '22 09:10

Mhmdrz_A