gluestack / gluestack-ui

React & React Native Components & Patterns (copy-paste components & patterns crafted with Tailwind CSS (NativeWind))
https://gluestack.io/
MIT License
2.56k stars 117 forks source link

Undocumented Next.js hydration error if the page is not enclosed by <main> tag #2081

Open Gwened opened 6 months ago

Gwened commented 6 months ago

Description

Unless the error can be fixed, the installation guide for Existing Projects should be updated, to help newcomers make it work: https://gluestack.io/ui/docs/guides/install-nextjs.

CodeSandbox/Snack link

No response

Steps to reproduce

  1. Create a project using npm create gluestack
  2. In /app/page, replace <main> and </main> by <Box> and </Box> (or with <div> or seemingly any other)
  3. Launch npm run dev
  4. See error:
    Error: Hydration failed because the initial UI does not match what was rendered on the server.
    Warning: Expected server HTML to contain a matching <div> in <div>.
    See more info here: https://nextjs.org/docs/messages/react-hydration-error

gluestack-ui Version

@gluestack/ui-next-adapter@2.1.11

Platform

Other Platform

No response

Additional Information

When <main> is not present the "gs-injected" div appears on server-side render, then disappears on client side.

surajahmed commented 5 months ago

@Gwened Thanks for reporting this. We'll try to reproduce and update you on this.

AlexCernik commented 4 months ago

Hi, any solution? @Gwened @surajahmed