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

Increment react and react-dom versions #543

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

turisap
Copy link

@turisap turisap commented Mar 12, 2021

This is a fix for the following 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 for tips about how to debug and fix this problem.

The error appears when an application using this package (we use the Toolbox component from the @nebula/editor) has version 17 and higher of react and react-dom installed. The only way I've found for now is to decrement versions of react and react-dom which is not really desirable.

  • incremented versions in the root package.json
  • incremented versions in modules/editor

@CLAassistant
Copy link

CLAassistant commented Mar 12, 2021

CLA assistant check
All committers have signed the CLA.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 2320

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 22.148%

Totals Coverage Status
Change from base Build 2307: 0.0%
Covered Lines: 1218
Relevant Lines: 5199

💛 - Coveralls

@ricricucit
Copy link

@turisap decrementing version does not seem to be enough.

I am now running on react and react-dom @16.14.0 and still getting:

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://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.

With stack trace pointing out src/toolbox.tsx:156:

  153 |   onSetModeConfig,
  154 |   onSetGeoJson,
  155 |   onImport,
> 156 | }: Props) {
  157 |   const [showConfig, setShowConfig] = React.useState(false);
  158 |   const [showImport, setShowImport] = React.useState(false);
  159 |   const [showExport, setShowExport] = React.useState(false);

Did you do anything else to actually skip this issue?

@ohlr
Copy link

ohlr commented Jul 19, 2021

@turisap @ricricucit any update on this? I just stumbled over this as well..
@turisap could you please sign the licensing agreement so this can get merged?

@ricricucit
Copy link

@ohlr Sorry for not following up here, but I made that working using an older React versions like @turisap was suggesting, but using npm-force-resolution.

FYI, in package.json:

  "dependencies": {
    ...
    "npm-force-resolutions": "0.0.10"
    ...
  }
  "resolutions": {
    "react": "^16.8.6",
    "react-dom": "^16.8.6"
  }

not an ideal solution, but made it work.
Eventually, I've implemented something custom.

@m-dad
Copy link

m-dad commented Aug 4, 2021

In my opinion React and React-DOM should be installed as dev-dependencies, so it would be compatible with all versions. We should point to the required React and React-DOM versions in peer-dependencies. If you agree I can send the pull request.

* incremented versions in the root package.json
* incremented versions in modules/editor
@turisap
Copy link
Author

turisap commented Aug 10, 2021

@ohlr sorry for not being up to date with this. I've just signed up the agreement and fixed email issues in my commits.

@igorDykhta igorDykhta self-requested a review February 12, 2022 00:26
@geometrikal
Copy link

Any idea how to get this to work? I have the same problem with the editor sample.

@jodusan
Copy link

jodusan commented Jan 11, 2023

This error is still showing, any ideas?

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

Successfully merging this pull request may close these issues.

9 participants