You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{useLocalStorage}from'react-use';constDemo=()=>{const[value,setValue]=useLocalStorage('my-key','foo');return(<div><div>Value: {value}</div><buttononClick={()=>setValue(prev=>{// prev value is always the samereturn'bar')}>bar</button></div>);};
What is the expected behavior?
the same behavior as in useState React hook
A little about versions:
React: 18.2.0
react-use: 17.5.0
The text was updated successfully, but these errors were encountered:
import{useLocalStorage}from'react-use';constDemo=()=>{const[value,setValue]=useLocalStorage('my-key','foo');return(<div><div>Value: {value}</div><buttononClick={()=>setValue(prev=>{// prev value is always the samereturn'bar')}>bar</button></div>);};
What is the expected behavior? the same behavior as in useState React hook
A little about versions:
React: 18.2.0
react-use: 17.5.0
I don't understand what's wrong, once the localstorage exists, it will not be initialized as 'foo', it will always be 'bar' at your code
What is the expected behavior?
the same behavior as in useState React hook
A little about versions:
react-use
: 17.5.0The text was updated successfully, but these errors were encountered: