chakra-pro-issues icon indicating copy to clipboard operation
chakra-pro-issues copied to clipboard

Hydration Errors

Open iMerica opened this issue 3 years ago • 3 comments

What component (if applicable)

  • Component name: Page Shells

Describe the bug I'm consistently seeing hydration errors in Next.js when rendering your components.

To Reproduce

  1. In latest Next.js with latest React
  2. Add a Chakra UI page shell to the app
  3. Refresh the page
  4. See error

Expected behavior I expect to be able to use the Page components as is using mainstream React tools like Next.js

Screenshots Screen Shot 2022-05-16 at 1 48 38 PM

Browser/Device (if applicable)

  • Chakra UI version [e.g. 1.1.6] latest
  • Browser [e.g. chrome, safari] Chrome latest

Additional context Add any other context about the problem here.

iMerica avatar May 16 '22 18:05 iMerica

Related: https://github.com/chakra-ui/chakra-ui/issues/5506

iMerica avatar May 16 '22 18:05 iMerica

Workaround:

const isDesktop = useBreakpointValue({ base: true, lg: true }, "base")

iMerica avatar May 16 '22 19:05 iMerica

@iMerica I was having the same "Hydration failed" issue with useBreakpointValue and Next.js and found this issue.

In my case, setting the defaultBreakpoint to base didn't work (same issue when loading the page directly) but it did work when I set defaultBreakpoint to, for example, lg.

Looking at the commit that introduced this argument, it looks like base is the default value passed into useBreakpoint so this shouldn't be occurring anymore regardless of providing the defaultBreakpoint. Anyway, just leaving this comment for the next person struggling with this.

mwakerman avatar May 23 '22 11:05 mwakerman