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
Hi, first of all, thank you for providing a nice library.
I love this and am learning a lot
I have some questions.
In your code, The useLocalStorage hook uses a custom event internally.
However, custom events could be triggered by not only internal function, but also other external functions anywhere.
I thought using local scope variable is more safe.
but if you have some reason using CustomEvent, could i ask??
// This is an example of a third-party store// that you might need to integrate with React.// If your app is fully built with React,// we recommend using React state instead.letnextId=0;lettodos=[{id: nextId++,text: 'Todo #1'}];letlisteners=[];exportconsttodosStore={addTodo(){todos=[...todos,{id: nextId++,text: 'Todo #'+nextId}]emitChange();},subscribe(listener){listeners=[...listeners,listener];return()=>{listeners=listeners.filter(l=>l!==listener);};},getSnapshot(){returntodos;}};functionemitChange(){for(letlisteneroflisteners){listener();}}
The text was updated successfully, but these errors were encountered:
Hi, first of all, thank you for providing a nice library.
I love this and am learning a lot
I have some questions.
In your code, The
useLocalStorage
hook uses a custom event internally.However, custom events could be triggered by not only internal function, but also other external functions anywhere.
I thought using local scope variable is more safe.
but if you have some reason using
CustomEvent
, could i ask??The text was updated successfully, but these errors were encountered: