million icon indicating copy to clipboard operation
million copied to clipboard

Hydration failed - Next.js 14

Open drewbitt opened this issue 1 year ago • 18 comments

What version of million are you using?

3.0.6

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Mac

What browser are you using?

Vivaldi (Chrome)

Describe the Bug

Info: Next.js 14.1.4, React 18.2.0 Node 18

const millionConfig = {
  auto: {
    rsc: true,
  },
};

I am getting a hydration error:

Unhandled Runtime Error
Error: Hydration failed because the initial UI does not match what was rendered on the server.

Warning: Did not expect server HTML to contain a <slot> in <slot>.

See more info here: https://nextjs.org/docs/messages/react-hydration-error

Component Stack
slot
MillionBlock
eval
ToastContextProvider
QueryClientProvider
SessionProvider
AppWrapper
MyApp

What's the expected result?

No errors. I do not have any slots in my code; this is all within Million itself and works without Million

This was not fixed with the previous report and fix in #977

Link to Minimal Reproducible Example

None - if I separate out the ToastContextProvider into a seperate app, I am not getting a reproduction, and as this is all within Million interacting with itself it is hard to do easily

Participation

  • [ ] I am willing to submit a pull request for this issue.

drewbitt avatar Mar 22 '24 18:03 drewbitt

Thanks for opening this issue! A maintainer will review it soon.

github-actions[bot] avatar Mar 22 '24 18:03 github-actions[bot]

Hmm, can you come into the server to report this @drewbitt? Maybe we can get on a call? We would need a reproduction before we're able to help.

https://million.dev/chat

tobySolutions avatar Mar 23 '24 12:03 tobySolutions

Having the same issue with Next.js 14.1.4 and pages router:

Error: Hydration failed because the initial UI does not match what was rendered on the server.

Warning: Did not expect server HTML to contain a <section> in <slot>.

See more info here: https://nextjs.org/docs/messages/react-hydration-error

Component Stack
slot
MillionBlock
eval
SectionLayoutContent
SectionPopularCompares
div
SectionHero
main
Layout
Page
LazyMotion
MotionConfig
PlausibleProvider
App

I get the same error with <footer> or <tr> elements. Changing these elements into a <div> removes most of the errors. But this cannot be a solution, especially with <tr> 😄

madebyfabian avatar Mar 28 '24 09:03 madebyfabian

Hmm, thank you very much for these. Really appreciate it. Can you please help with a reproduction though? I use Million in Nextjs pages router app and I don't get this issue at all.

Hey @drewbitt, why are you using this specific configuration?

const millionConfig = {
  auto: {
    rsc: true,
  },
};

Please refer to the documentation here: https://million.dev/docs/install#install-manually

tobySolutions avatar Mar 29 '24 20:03 tobySolutions

@tobySolutions Sorry! Of course, here is a reproduction. It has a slightly different error message, but it's the same issue. It's a blank next.js project (pages router), where I just added a <table> and <section> component https://stackblitz.com/github/madebyfabian/nextjs-million-reprod?file=pages%2Findex.tsx

madebyfabian avatar Mar 30 '24 06:03 madebyfabian

@tobySolutions Sorry! Of course, here is a reproduction. It has a slightly different error message, but it's the same issue. It's a blank next.js project (pages router), where I just added a <table> and <section> component https://stackblitz.com/github/madebyfabian/nextjs-million-reprod?file=pages%2Findex.tsx

Awesome! Thank you very much, I really appreciate it.

tobySolutions avatar Mar 30 '24 23:03 tobySolutions

Hey there @drewbitt, can you maybe try this config?

import million from 'million/compiler'

/** @type {import('next').NextConfig} */
const nextConfig = {
	reactStrictMode: true,
}

export default million.next(nextConfig, {
	auto: true,
	server: true,
	rsc: true,
})

tobySolutions avatar Mar 30 '24 23:03 tobySolutions

I appreciate the reproduction @madebyfabian and the config @tobySolutions. The config update does fix this for me and I do not have the hydration error. I assume the docs should be updated as I was not seeing this as the recommended config for Nextjs.

drewbitt avatar Apr 01 '24 04:04 drewbitt

Actually though, I see that in my code and the reproduction, before I was getting notice of each component and how much Million speeds things up. Changing it to that config however which makes this not break disables that printout, so I'm not sure Million is working at all.

Before: image

After: image

drewbitt avatar Apr 01 '24 04:04 drewbitt

drewbitt

Having the same issue

fristyr avatar Apr 13 '24 16:04 fristyr

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days.

github-actions[bot] avatar Apr 29 '24 00:04 github-actions[bot]

Not stale. That's aggressive.

drewbitt avatar Apr 29 '24 03:04 drewbitt

Actually though, I see that in my code and the reproduction, before I was getting notice of each component and how much Million speeds things up. Changing it to that config however which makes this not break disables that printout, so I'm not sure Million is working at all.

Before: image

After: image

Hey there, sorry for the late response on this. Can you try reverting to the previous config then? You shouldn't be getting hydration errors though.

tobySolutions avatar May 03 '24 07:05 tobySolutions

Reverting it to the previous config would just be the reproduction of the hydration error in stackblitz.com/github/madebyfabian/nextjs-million-reprod?file=pages%2Findex.tsx above, no? Do you mean something else?

drewbitt avatar May 03 '24 15:05 drewbitt

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days.

github-actions[bot] avatar May 19 '24 00:05 github-actions[bot]

Not resolved. Let me know if you're waiting on me for anything.

drewbitt avatar May 19 '24 00:05 drewbitt

Same issue here. I seem to see it with SVG icons sometimes and then it seems a hidden sidebar on mobile with a 'ul' tag has the issue. Does not happen on desktop where the sidebar is shown from the beginning

devotox avatar May 25 '24 12:05 devotox

Having this issue as well.

conors06 avatar Jun 06 '24 21:06 conors06