store data in localstorage react code example
Example 1: save data in local storage reactjs returns [object, object]
Local Storage is key-value storage where key is string and value is string also.
You must stringify your data, you can do this
localStorage.setItem('user', JSON.stringify(user));
And get it like
const user = JSON.parse(localStorage.getItem('user'));
Example 2: react localstorage
localStorage.setItem('myData', data);
localStorage.getItem('myData');
localStorage.removeItem('myData');
localStorage.clear();