I'm using a components library with @emotion/styled components (MUI components). I don't use any emotion cache.
As I understood it, it looks like vite-react-ssg prerender components server-side, and so I got this error because of this :
[vite-react-ssg] error: TypeError: Cannot read properties of null (reading 'registered')
at file:///Users/<COMPONENT_LIBRARY>/dist/react-uikit.js:3258:49
at file:///Users/<COMPONENT_LIBRARY>/dist/react-uikit.js:3174:12
at renderWithHooks (/<MY_PROJECT_PATH>/node_modules/react-dom/cjs/react-dom-server.node.development.js:5724:16)
at renderForwardRef (/<MY_PROJECT_PATH>/node_modules/react-dom/cjs/react-dom-server.node.development.js:5919:18)
at renderElement (/<MY_PROJECT_PATH>/node_modules/react-dom/cjs/react-dom-server.node.development.js:6082:11)
at renderNodeDestructiveImpl (/<MY_PROJECT_PATH>/node_modules/react-dom/cjs/react-dom-server.node.development.js:6181:11)
at renderNodeDestructive (/<MY_PROJECT_PATH>/node_modules/react-dom/cjs/react-dom-server.node.development.js:6153:14)
at renderForwardRef (/<MY_PROJECT_PATH>/node_modules/react-dom/cjs/react-dom-server.node.development.js:5936:5)
at renderElement (/<MY_PROJECT_PATH>/node_modules/react-dom/cjs/react-dom-server.node.development.js:6082:11)
at renderNodeDestructiveImpl (/<MY_PROJECT_PATH>/node_modules/react-dom/cjs/react-dom-server.node.development.js:6181:11)
If i dig into the lines :
Any ideas ?
(I already tried to set @emotion/styled as a peerDep in my components library, and dedupe it in the vite.config of my project).
An "ugly" solution :
I succeeded to fix this by using <ClientOnly> in my project around my library components, but this look quite ugly.
I'm using a components library with @emotion/styled components (MUI components). I don't use any emotion cache.
As I understood it, it looks like vite-react-ssg prerender components server-side, and so I got this error because of this :
If i dig into the lines :
Any ideas ?
(I already tried to set @emotion/styled as a peerDep in my components library, and dedupe it in the vite.config of my project).
An "ugly" solution :
I succeeded to fix this by using
<ClientOnly>
in my project around my library components, but this look quite ugly.