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

Context does not work with SSR #98

Open
efoken opened this issue Oct 8, 2022 · 0 comments
Open

Context does not work with SSR #98

efoken opened this issue Oct 8, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@efoken
Copy link
Contributor

efoken commented Oct 8, 2022

Describe the bug
When using createContext, SSR is broken for me. I'm getting this errors in the console when starting Next.js:

ReferenceError: CustomEvent is not defined
     at dispatchEvent (file:///Users/eike.foken/Code/test-ui/node_modules/.pnpm/[email protected]/node_modules/atomico/src/element/set-prototype.js:95:50)
     at ref.<computed> (file:///Users/eike.foken/Code/test-ui/node_modules/.pnpm/[email protected]/node_modules/atomico/src/hooks/custom-hooks/use-event.js:11:13)
     at detectContext (file:///Users/eike.foken/Code/test-ui/node_modules/.pnpm/[email protected]/node_modules/atomico/src/context.js:21:9)
     at load (file:///Users/eike.foken/Code/test-ui/node_modules/.pnpm/[email protected]/node_modules/atomico/src/hooks/hooks.js:19:56)
     at file:///Users/eike.foken/Code/test-ui/node_modules/.pnpm/[email protected]/node_modules/atomico/src/hooks/hooks.js:21:24
     at useHook (file:///Users/eike.foken/Code/test-ui/node_modules/.pnpm/[email protected]/node_modules/atomico/src/hooks/create-hooks.js:14:15)
     at useState (file:///Users/eike.foken/Code/test-ui/node_modules/.pnpm/[email protected]/node_modules/atomico/src/hooks/hooks.js:17:12)
     at useContext (file:///Users/eike.foken/Code/test-ui/node_modules/.pnpm/[email protected]/node_modules/atomico/src/context.js:35:49)
     at useTheme (webpack-internal:///../packages/styles/src/theme/theme-provider.ts:19:68)

And also later on (if I polyfill CustomEvent with an empty function):

TypeError: node.dispatchEvent is not a function

Expected behavior
No errors in console

*SSR/SSG environment (Optional, required if the problem is caused by using SSR/SSG, please complete the following information):

@efoken efoken added the bug Something isn't working label Oct 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant