mantine: Mantine >v5.3.3 is not working with Next.js SSR (TypeError: useInsertionEffect)
What package has an issue
Describe the bug
I am using mantine version ^5.3.3 with next.js 13.0.1.
When I upgrade to a newer mantine version, e.g. ^5.4.0 or ^5.7.0 I get the following error when opening my website:
error - TypeError: dispatcher.useInsertionEffect is not a function
at useInsertionEffect (C:\pathToMyProject\node_modules\react\cjs\react.development.js:1638:21)
at useEvent (C:\pathToMyProject\node_modules\@floating-ui\react-dom-interactions\dist\floating-ui.react-dom-interactions.umd.js:186:7)
at Object.useFloating (C:\pathToMyProject\node_modules\@floating-ui\react-dom-interactions\dist\floating-ui.react-dom-interactions.umd.js:223:26)
at Object.usePopover (C:\pathToMyProject\node_modules\@mantine\core\cjs\Popover\use-popover.js:45:41)
at Popover (C:\pathToMyProject\node_modules\@mantine\core\cjs\Popover\Popover.js:134:30)
at renderWithHooks (C:\pathToMyProject\node_modules\react-ssr-prepass\dist\react-ssr-prepass.js:454:15)
at render$2 (C:\pathToMyProject\node_modules\react-ssr-prepass\dist\react-ssr-prepass.js:465:6)
at C:\pathToMyProject\node_modules\react-ssr-prepass\dist\react-ssr-prepass.js:612:12
at render (C:\pathToMyProject\node_modules\react-ssr-prepass\dist\react-ssr-prepass.js:613:4)
at visitElement (C:\pathToMyProject\node_modules\react-ssr-prepass\dist\react-ssr-prepass.js:725:15) {
page: '/webinars/[id]'
}
Thanks for this awesome library and taking time for this issue š
What version of @mantine/hooks page do you have in package.json?
^5.4.0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 20 (3 by maintainers)
@peter-wd-1 I also found that the Select component was giving me the
TypeError: useInsertionEffect only works in Client Components. The workaround I found in next is to dynamically import the component withssr: falsein the import, like so:It works well for what I am doing, I hope this helps someone else.
It was the same for me. Commenting out the
<Select />component worked for me. I wonder why that is.Iām having the same
TypeError: useInsertionEffect only works in Client Componentsissue. Unfortunately I canāt use one of the suggested templates as @rtivital has suggested as Iām already using a Next / tRPC template. Tried clearing the cache and reinstalling deps to no avail.Had to go with turning off SSR in the tRPC config for now. Hopefully there will be a fix that doesnāt require this down the line.
Note: After some messing around, I found that I donāt get the error with some of the components even with SSR enabled. It appears the Mantineās
<Select/>component was the offending one for me. Maybe others can corroborate?I found a same error Just running
next devcause me this@mantine/coreversion:^5.6.3Probably this is during the
react-ssr-prepassissue, the package is not actively maintained but used in SSR render of tRPC.I stumbled upon the same error in another library though.
Upd: I created an issue in tRPC for that, itās the best shot to get this fixed.
I use Mantine, but without any
<Select/>until now and the error is still there with ā@mantine/coreā: ā^6.0.10ā.There still must be another mantine component, which breaks tRPC SSR. š¦