Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Did not expect server HTML to contain [..]" during dynamic import #6904

Closed
oMatej opened this issue Apr 5, 2019 · 10 comments
Closed

"Did not expect server HTML to contain [..]" during dynamic import #6904

oMatej opened this issue Apr 5, 2019 · 10 comments

Comments

@oMatej
Copy link

oMatej commented Apr 5, 2019

Bug report

Describe the bug

Dynamic import of components with "re-export" by index.js file leads to following warnings:
Warning: Did not expect server HTML to contain a <h2> in <div>.

To Reproduce

  1. Create a file which will export many dynamically imported components, i.e.:
  • Import one component directly.
  • Import other component through index.js with export { default } from './World'
export const Hello = dynamic(import('./Hello/Hello'));
export const World = dynamic(import('./World'));
  1. Use both components on page.
  2. Run application in development mode with yarn dev / npm run dev.
  3. In the browser console there will be mentioned warning.

Here is example repository: https://github.com/oMatej/next-dynamic-import-issue

Expected behavior

Both types of imports should behave the same.

System information

  • OS: Ubuntu 18.04.1 LTS
  • Version of Next.js: 8.0.4
@jacobrask
Copy link

It seems like the only way around this is to make sure all imports in the module you loaded dynamically are also wrapped in dynamic.

@einarlove
Copy link

Having the same issue. Hard to pinpoint the problem but it looks like it fails when trying to import something outside its bundle. ¯_(ツ)_/¯

@adam187

This comment has been minimized.

@timneutkens
Copy link
Member

timneutkens commented Jun 6, 2019

Note that it's a bad idea to suppress hydration warnings. It will hide problems in your application.

@cesarvarela
Copy link

I'm having the same issue, is this something new to next 8?

@cesarvarela
Copy link

Just tried downgrading my project to next 7, and it fixes the issue.

This is happening to me in dev mode, in production seems to be working fine on both 7 and 8.

@timneutkens
Copy link
Member

Can you try next@canary?

@jacobrask
Copy link

I have done that previously, is something recently released?

@timneutkens
Copy link
Member

Yep I think @Timer landed a patch for next/dynamic, not entirely sure if it's directly related, but doesn't hurt to try.

@Timer
Copy link
Member

Timer commented Jun 24, 2019

I confirmed this was fixed by my PR, upgrading to the latest canary will fix this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants