//Set item
localStorage.setItem('myCat', 'Tom');
//Get item
var cat = localStorage.getItem("myCat");
//Remove item
localStorage.removeItem("lastname");
//Remove all items
localStorage.clear();
localStorage.setItem('myCat', 'Tom');
var cat = localStorage.getItem('myCat');
localStorage.removeItem('myCat');
// Clear all items
localStorage.clear();
window.localStorage.setItem('name', 'Obaseki Nosa');
// Store
localStorage.lastname = "Smith";
// Retrieve
document.getElementById("result").innerHTML = localStorage.lastname;
// Remove
localStorage.removeItem("lastname");
const person = {
name: "Obaseki Nosa",
location: "Lagos",
}
window.localStorage.setItem('user', JSON.stringify(person));
window.localStorage.getItem('user');
var cat = localStorage.getItem('myCat');
//useEffect(function (){}, []) this hook takes function as its first argument and an array/dependency as
//which if the [] arrray is empty it runs once, meaning on initial render
useEffect(() => {
const previousData = JSON.parse(localStorage.getItem("Todos"));
setTodos(previousData);
},[])
//and if something changes in the dependency's value in this case inputText the function that is passed as the first argument runs each time
useEffect(() => {
localStorage.setItem('Todos', JSON.stringify(Todos));
}, [inputText])