Skip to content

Invalid Hook call on using a custom header #6331

Description

@D4uS1

If you follow the documentation and create a custom header component, the page crashes with the console error message:

Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app
    See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.
    at Object.DateFieldCustomHeader [as renderCustomHeader]
    This is a duplicate of this issue.

The problem here is, that you defined react and react-dom as a peer dependency, but also as a dev dependency.
Since npm tries to resolve peer depdendencies and only installs them once, this is not necessary.
The dev depdendency causes npm to install react twice if it does not match the peer dependency.

I apologize that i do not provide a pull request, but since you use yarn for your project and i won't like to install yarn to only remove this two lines, i would thank you very much if you just fix this, test it and provide a new version :).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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