Skip to content

React memo is not considered a valid react component #5692

Closed
@nassimbenkirane

Description

@nassimbenkirane

Bug report

React.memo for page components

Describe the bug

When using React.memo as the exported component in a page, Next JS throws an error :
The default export is not a React Component in page: "/"

To Reproduce

You can check the behaviour here :
https://codesandbox.io/s/k2jx562o3

Expected behavior

The memo component should be considered a valid component

Screenshots

capture d ecran 2018-11-16 a 21 41 55

System information

  • Version of Next.js: [7.0.2]

Additional context

When adding memo to the component while hot reloading is active, it doesn't throw the error.
In that case, the error occurs only on first load, or when we reload the page.

Probably because of this line
https://github.com/zeit/next.js/blob/b63dda7cf7e9a58c3687fb8007c1d899b692584d/packages/next-server/server/render.js#L86

Switching to react-is would probably solve it and make this condition future-proof

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions