Comments (6)
Sorry, didn't see your instructions above.
Indeed I can reproduce the issue, and get the following errors in dev mode:
react-dom.development.js:86 Warning: Expected server HTML to contain a matching <ul> in <p>.
react-dom.development.js:12507 Uncaught Error: Hydration failed because the initial UI does
react-dom.development.js:86 Warning: An error occurred during hydration. The server HTML was replaced with client content in <div>.
react-dom.development.js:86 Warning: validateDOMNesting(...): <ul> cannot appear as a
This is not a valid repro because it is forbidden to put ul
in a paragraph, as stated in the error message.
<p>
<ul>
<li>foo</li>
<li>bar</li>
</ul>
</p>
You can find many resources related to what cause hydration errors in React online. Those apply to Docusaurus as well.
from docusaurus.
This is likely not a regression: it was a hydration error that was already there, but React did not tell you about it.
React < 18 did not tell you about such problems, and now it does.
The init template of Docusaurus does not have such hydration errors, so it is very likely your code that produces such problems. Try to remove your code until it fixes the problem. Running in docusaurus build --dev
mode might help identify the problematic code (although in my experience it also produces false positive errors)
from docusaurus.
Thanks. Using the trick of --dev
, I isolated the problem to a bulleted list.
To reproduce the problem, you can use the following steps:
npx create-docusaurus@latest my-website classic --typescript
cd my-website
npm run build && npm run serve
Obviously, observe that there are no errors (since it is a fresh template).
Then, open "./src/components/HomepageFeatures/index.tsx" and change the following text:
<>
Docusaurus was designed from the ground up to be easily installed and
used to get your website up and running quickly.
</>
To this:
<>
<ul>
<li>foo</li>
<li>bar</li>
</ul>
</>
Then, run npm run build && npm run serve
, and you will see the same run-time errors that I was describing in the OP.
Any idea what is wrong? I tried a few things, including changing the fragment (i.e. <>
) to <div>
, but nothing I tried got past this error.
from docusaurus.
I don't know what the problem is.
Sometimes an external script, or even a browser extension, can lead to such hydration errors
from docusaurus.
I can reproduce the issue on Microsoft Edge, which does not have any browser extensions. Thus, I assume that this is reproducible for everybody by copy-pasting the steps from my previous post (not OP). Do you want me to open a new issue?
from docusaurus.
If you want to open an issue, please create a minimal repro instead of giving us a link to an existing site. Start from a brand new Docusaurus site, and add the smallest possible changes to make the issue appear.
I can't spend hours investigating your existing site and removing things one by one until we know what causes the problem, so I kindly ask you to do this investigation first before opening this issue. If you can't repro from a newly initialized site, that's likely a bug you introduced, by using code or a third-party plugin that has a bug.
from docusaurus.
Related Issues (20)
- Index pages cannot be generated with an automatically generated siderbar HOT 1
- Document solution to "docs last update" date being rendered incorrectly when published through Vercel
- Customizing admonitions not work HOT 3
- When testing on StrictMode, the bar remains on the top HOT 1
- Node.js building getting stuck HOT 2
- Updating to @mdx-js/react 3.0.1 causes admonition blocks to stop rendering colored box HOT 8
- The <!--truncate--> line in my long blog post on the initialized website is not causing the blog post size to be limited. HOT 1
- Add trailing slash to auto generated sitemap.xml for directories only HOT 3
- blogTitle not working HOT 4
- Algolia Contextual Search Generates Incorrect FaceFilters HOT 6
- Multi-Instance Routes Not Working in v3.2.1 HOT 3
- Home page renders twice, one below the other. HOT 1
- Details elements aren't searchable - a11y issue HOT 8
- WARNβ 1 deprecated subdependencies found: [email protected] HOT 1
- npm run build fails when nmetadata are missing HOT 3
- Broken link transformation HOT 2
- Ability to Skip Homepage and Directly Access Feature Page HOT 1
- Light/Dark Mode issues on older versions of Safari 12,13, and 14 HOT 3
- Problems with locale url on homepage and blog HOT 1
- Proposal: createSitemapItems hook - a sitemap equivalent to createFeedItems
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docusaurus.