If we want to save string in localstorage , we can save simply like
and we can get data from local storage as follows :
But if we want to save data in array and objects format , we need to convert array and objects in string format using stringify method.
When we need to get the saved array and objects we can convert stringified array and objects using parse method.
Example below :
in the App.js :
Hope you try the code in your App.js file and if you want to check where localstorage is in the browser
Check the image below :
Goto Application --> localstorage --> http://localhost:3000/
If you face any issues let me know in the comments section , hope it helps you . Best of Luck
Comments
Post a Comment