Hello guys! I am trying to store my counter (which counts the no. of attempts ) in my local storage, it is storing in local storage but when i try to fetch in (val variable) it shows null value for that i am not able to figure out why it is happening....
const [counter,setcounter] =React.useState(0);
React.useEffect(() => {
const allHeld = dice.every(die => die.isHeld)
const firstValue = dice[0].value
const allSameValue = dice.every(die => die.value === firstValue)
if (allHeld && allSameValue) {
setTenzies(true)
var itemSet = (window.localStorage.getItem('tenzies_max') === null);
if(itemSet){
window.localStorage.setItem('tenzies_max',`${counter}`);
}
else{
if(window.localStorage.getItem('tenzies_game')>`${counter}`)
window.localStorage.setItem('tenzies_game',`${counter}`);
}
var val=window.localStorage.getItem('tenzies_game');
console.log(val)
}
}, [dice])