Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Uncaught (in promise) TypeError: Cannot read property 'emit' of null" #56

Open
vidjuheffex opened this issue Jun 30, 2021 · 7 comments

Comments

@vidjuheffex
Copy link

when I call the setState in a subsequent useEffect call I get this.

Seems to work, but the next call is not valid.

@szotyi41
Copy link

szotyi41 commented Jul 8, 2021

I got the same error sometimes. Waiting for a workaround

@buckie
Copy link

buckie commented Jul 9, 2021

@szotyi41 I used this to work around the bug:

  //Wallet State
  const [persistedWallet,setPersistedWallet] = createPersistedState("wallet")({wallet: "Chainweaver"});
  const [walletProvider,setWalletProvider] = useState(persistedWallet);
  // Experimental wrapper for "emit" bug found in https://github.com/donavon/use-persisted-state/issues/56
  useEffect(()=>setPersistedWallet(walletProvider),[persistedWallet, walletProvider, setPersistedWallet]);

@alexcastillo
Copy link

I'm experiencing this issue as well. It only happens with prod builds and not during dev.

@alexcastillo
Copy link

Temporary workaround is to wrap set setState function inside a try/catch block.

@sanojsilva
Copy link

Same happens to me when I setState inside a useEffect hook

@garrettmaring
Copy link

is it possible that this was a regression? i've only just started experiencing this

@rwieruch
Copy link

rwieruch commented Dec 8, 2021

Seeing this as well in development when I create multiple persisted states on multiple pages, all with different keys.

"use-persisted-state": "^0.3.3"

EDIT: Because of #36, I am using https://www.npmjs.com/package/use-local-storage-state now. It works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants