Repository navigation
Closed
Labels
bugAn error in the Docusaurus core causing instability or issues with its executiondomain: themeRelated to the default theme components
Milestone
Description
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I'm using the latest version of Docusaurus.
- I have tried the
npm run clearoryarn clearcommand. - I have tried
rm -rf node_modules yarn.lock package-lock.jsonand re-installing packages. - I have tried creating a repro with https://new.docusaurus.io.
- I have read the console error message carefully (if applicable).
Description
It will break when using Docusaurus v2.3 and React 18 with Tabs, when yarn building.
[ERROR] Docusaurus server-side rendering could not render static page with path /docs/in
tro.
Error: Missing getServerSnapshot, which is required for server-rendered content. Will revert to client rendering.
[ERROR] Unable to build website for locale en.
[ERROR] Error: Failed to compile with errors.
at /sandbox/node_modules/@docusaurus/core/lib/webpack/utils.js:180:24
at /sandbox/node_modules/webpack/lib/MultiCompiler.js:554:14
at processQueueWorker (/sandbox/node_modules/webpack/lib/MultiCompiler.js:491:6)
at processTicksAndRejections (node:internal/process/task_queues:78:11)
[INFO] Docusaurus version: 2.3.0
Node version: v16.15.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Reproducible demo
Steps to reproduce
- Install a fresh Docusaurus 2.3
yarn add react@18 react-dom@18- Add the following:
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; <Tabs> <TabItem value="option 1" label="option 1"> 1 </TabItem> <TabItem value="option 2" label="option 2"> 2 </TabItem> </Tabs> yarn devworks.yarn buildfails.
Expected behavior
The build should not fail.
Actual behavior
The build fails.
Your environment
- Public source code: https://codesandbox.io/s/hungry-hodgkin-2z1jdc
- Public site URL: https://2z1jdc.sse.codesandbox.io/docs/intro
- Docusaurus version used: 2.3
- Environment name and version (e.g. Chrome 89, Node.js 16.4): Node v16.15.1
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): CodeSandBox
Self-service
- I'd be willing to fix this bug myself.
Reacted by Valentine, Tim Kolberger, Teo Stocco, EL AYADI Mohamed and miguelSWE
Metadata
Metadata
Assignees
Labels
bugAn error in the Docusaurus core causing instability or issues with its executiondomain: themeRelated to the default theme components
Activity
Josh-Cena commentedon Jan 28, 2023
Thanks for the report. This is due to the use of
useSyncExternalStore.slorber commentedon Feb 2, 2023
Not sure to understand why you want to use React 18 here @anaclumos , we don't officially support it so do we really want to qualify this as a bug? Similarly, if you decide to use Docusaurus 2.3 with React 0.13, things will break 🤷♂️
Technically there's probably a way to make it work under React 18 but is it really worth it to invest time in solving this?
You could stick to React 17 until we provide official React 18 support?
We could as well make any Docusaurus site on React !== 17 fail fast and print a good error message that we do not support React 18?
It's not because it "seems to work" that it actually do, there might be subtle hydration bugs triggered by using React 18, for which we don't want to spend time on support.
Our peer deps do not include React 18 atm. Are we even sure that sites using React 18 aren't running duplicate non-hoisted React copies?
Edit: apparently yarn will not report any error but npm will do:
quick fix of useSyncExternalStore for React 18 support, see #8592
slorber commentedon Feb 2, 2023
Fix was easy so we'll merge/release it, but I don't particularly recommend React 18 for now. Other similar things might break and we don't even build our own site under React 18 with our CI so we are less likely to notice when things break.
PR: #8618
slorber commentedon Feb 2, 2023
please test the canary release and let me know if this doesn't work. On a newly initialized site it works 👍
incepter commentedon Feb 2, 2023
Hey @slorber ; I just had the same issue and I was coming here to create it :-) Thanks for resolving it already
I honestly didn't pay attention to react version support, I have it in my monorepo more than year now I didn't have problems.
The reason for me to use react 18 is that it I use it practically everywhere I use React. Especially in the monorepo of my library. I think I can downgrade react specifically for the docs package (I didn't know about this), but I think waiting for the patch is worth it.
Please let us know when it may get released ? Thanks again.
Josh-Cena commentedon Feb 2, 2023
Re: why many use React v18, it's because of the nice hooks like
useId(), which is necessary for a11y.anaclumos commentedon Feb 2, 2023
Just an FYI, I use React 18 for useId() and https://github.com/shuding/react-wrap-balancer