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
If a value is initialized through defaultValue, the value is not set in the session storage.
Expected behavior
Even if the set function is not executed, if the value is initialized through defaultValue, the value must be set in the session storage.
To Reproduce
const[state,set]=useStorageState('dummy-key',{defaultValue: 'foo'});// it doesn't stored in session storage until we call set funciton
Possible Solution
constgetValue=useCallback(<T>()=>{constdata=storage.get(key);if(data==null){returndefaultValue;}try{constresult=JSON.parse(data);if(result==null){storage.set(key,JSON.stringify(defaultValue));// add this linereturndefaultValue;}returnresultasT;}catch{// NOTE: JSON 객체가 아닌 경우returndefaultValue;}},[defaultValue,key,storage]);
Package Scope
Package name: @toss/react
Describe the bug
If a value is initialized through
defaultValue, the value is not set in thesession storage.Expected behavior
Even if the set function is not executed, if the value is initialized through
defaultValue, the value must be set in thesession storage.To Reproduce
Possible Solution
Additional context