Home > OS >  I have an array of objects stored in local storage, but I want to be able to use the contents of eac
I have an array of objects stored in local storage, but I want to be able to use the contents of eac

Time:11-02

array of objects

i am expecting to be able to target the id and use it where I want and the name and also use it where i want.

CodePudding user response:

You can use Redux & Redux Toolkit in ReactJS and make your store with reducers and actions then using useSelector Hook to use it in any component.

Tutorials for this: https://redux-toolkit.js.org/tutorials/quick-start

CodePudding user response:

After you get the array of objects from the localStorage, you can use .find() to find a single object by id, for example. You could also use .filter() if you need to filter array down based on some other property.

  • Related