diff --git a/src/usePersistedState.js b/src/usePersistedState.js index f1d7fbf..12d7e92 100644 --- a/src/usePersistedState.js +++ b/src/usePersistedState.js @@ -20,7 +20,7 @@ const usePersistedState = (initialState, key, { get, set }) => { // only called on mount useEffect(() => { // register a listener that calls `setState` when another instance emits - globalState.current = createGlobalState(key, setState, initialState); + globalState.current = createGlobalState(key, setState, state); return () => { globalState.current.deregister();