Versions missmatch between "react" and "react-dom" after switch to UI kit 2 (GA)

Hi community,

Once I updated the version of forge/react to 10.0.0 I started to get the same React error in my app on the front-end part of it (love minified included :confused: ):

react.production.min.js:19 Uncaught Error: Minified React error #321; visit https://reactjs.org/docs/error-decoder.html?invariant=321 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    at U (react.production.min.js:19:404)
    at t.useState (react.production.min.js:25:277)
    at t.ModalsProvider (ModalContext.tsx:43:51)
    at Fn (react-reconciler.production.min.js:81:137)
    at wi (react-reconciler.production.min.js:199:332)
    at Ki (react-reconciler.production.min.js:189:389)
    at Wi (react-reconciler.production.min.js:189:320)
    at Gi (react-reconciler.production.min.js:189:180)
    at Ni (react-reconciler.production.min.js:182:245)
    at Zt (react-reconciler.production.min.js:41:105)

Or this in normal language:

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.

As far as it worked before the forge/react version update, I suppose that it’s related more to 1 or 3 options.

Here is the list of dependencies I use in my project from package.json:

  "dependencies": {
    "@forge/api": "^3.2.0",
    "@forge/events": "^0.8.29",
    "@forge/react": "^10.0.0",
    "@forge/resolver": "^1.5.28",
    "@forge/ui": "^1.11.0",
    "http-status-codes": "^2.3.0",
    "js-tiktoken": "^1.0.10",
    "nanoid": "^5.0.6",
    "openai": "^4.28.4"
  },
  "devDependencies": {
    "@types/node": "^20.11.25"
  }

Once I ran a test command to check current React dependencies and version used for react-dom found this:

PS C:\Users\Admin\workspace\just> npm list react-dom                    
just@0.3.0 C:\Users\Admin\workspace\just
`-- @forge/react@10.0.0
  `-- @atlaskit/forge-react-types@0.5.2
    +-- @atlaskit/dynamic-table@14.14.0
    | +-- react-beautiful-dnd@12.2.0
    | | `-- react-dom@16.14.0 deduped
    | `-- react-dom@16.14.0
    +-- @atlaskit/modal-dialog@12.10.8
    | `-- @atlaskit/portal@4.4.0
    |   `-- react-dom@16.14.0 deduped
    +-- @atlaskit/progress-tracker@8.5.8
    | `-- react-transition-group@4.4.5
    |   `-- react-dom@16.14.0 deduped
    +-- @atlaskit/select@17.2.0
    | +-- react-dom@16.14.0 deduped
    | +-- react-popper@2.3.0
    | | `-- react-dom@16.14.0 deduped
    | `-- react-select@5.8.0
    |   `-- react-dom@16.14.0 deduped
    `-- @atlaskit/tooltip@18.1.2
      `-- react-dom@16.14.0 deduped

And for react:

PS C:\Users\Admin\workspace\just> npm list react    
just@0.3.0 C:\Users\Admin\workspace\just
`-- @forge/react@10.0.0
  +-- @atlaskit/forge-react-types@0.5.2
  | +-- @atlaskit/badge@15.2.4
  | | +-- @atlaskit/ds-explorations@3.2.4
  | | | `-- react@16.14.0 deduped
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/button@17.6.2
  | | +-- @atlaskit/analytics-next@9.2.0
  | | | +-- @atlaskit/analytics-next-stable-react-context@1.0.1
  | | | | `-- react@16.14.0 deduped
  | | | +-- react@16.14.0 deduped
  | | | `-- use-memo-one@1.1.3
  | | |   `-- react@16.14.0 deduped
  | | +-- @atlaskit/ds-lib@2.2.4
  | | | `-- react@16.14.0 deduped
  | | +-- @atlaskit/focus-ring@1.3.7
  | | | `-- react@16.14.0 deduped
  | | +-- @atlaskit/icon@22.1.1
  | | | `-- react@16.14.0 deduped
  | | +-- @atlaskit/interaction-context@2.1.3
  | | | `-- react@16.14.0 deduped
  | | +-- @atlaskit/theme@12.6.4
  | | | `-- react@16.14.0 deduped
  | | +-- @atlaskit/tokens@1.39.1
  | | | `-- react@16.14.0 deduped
  | | +-- @atlaskit/visually-hidden@1.2.4
  | | | `-- react@16.14.0 deduped
  | | +-- @emotion/react@11.11.4
  | | | +-- @emotion/use-insertion-effect-with-fallbacks@1.0.1
  | | | | `-- react@16.14.0 deduped
  | | | `-- react@16.14.0 deduped
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/checkbox@13.0.1
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/code@15.1.0
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/dynamic-table@14.14.0
  | | +-- @atlaskit/pagination@14.6.0
  | | | `-- react@16.14.0 deduped
  | | +-- react-beautiful-dnd@12.2.0
  | | | +-- react-redux@7.2.9
  | | | | `-- react@16.14.0 deduped
  | | | `-- react@16.14.0 deduped
  | | +-- react-dom@16.14.0
  | | | `-- react@16.14.0 deduped
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/form@9.0.10
  | | +-- react-uid@2.3.3
  | | | `-- react@16.14.0 deduped
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/heading@1.6.0
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/lozenge@11.6.4
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/modal-dialog@12.10.8
  | | +-- @atlaskit/blanket@13.0.0
  | | | `-- react@16.14.0 deduped
  | | +-- @atlaskit/layering@0.2.3
  | | | `-- react@16.14.0 deduped
  | | +-- @atlaskit/motion@1.5.1
  | | | `-- react@16.14.0 deduped
  | | +-- @atlaskit/portal@4.4.0
  | | | `-- react@16.14.0 deduped
  | | +-- react-focus-lock@2.11.2
  | | | +-- react-clientside-effect@1.2.6
  | | | | `-- react@16.14.0 deduped
  | | | +-- react@16.14.0 deduped
  | | | +-- use-callback-ref@1.3.1
  | | | | `-- react@16.14.0 deduped
  | | | `-- use-sidecar@1.1.2
  | | |   `-- react@16.14.0 deduped
  | | +-- react-scrolllock@5.0.1
  | | | `-- react@16.14.0 deduped
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/primitives@4.0.0
  | | +-- @atlaskit/app-provider@1.0.0
  | | | `-- react@16.14.0 deduped
  | | +-- @atlaskit/css@0.0.3
  | | | +-- @compiled/react@0.16.10
  | | | | `-- react@16.14.0 deduped
  | | | `-- react@16.14.0 deduped
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/progress-bar@2.0.1
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/progress-tracker@8.5.8
  | | +-- react-transition-group@4.4.5
  | | | `-- react@16.14.0 deduped
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/radio@6.0.2
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/range@7.1.7
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/section-message@6.4.21
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/select@17.2.0
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/tag@12.0.1
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/textarea@5.0.1
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/textfield@6.0.1
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/toggle@13.0.3
  | | `-- react@16.14.0 deduped
  | +-- @atlaskit/tooltip@18.1.2
  | | +-- @atlaskit/popper@5.5.4
  | | | `-- react@16.14.0 deduped
  | | `-- react@16.14.0 deduped
  | `-- react@16.14.0
  +-- react-hook-form@7.51.0
  | `-- react@16.14.0 deduped
  +-- react-reconciler@0.29.0
  | `-- react@18.2.0 deduped
  +-- react-test-renderer@18.2.0
  | +-- react-shallow-renderer@16.15.0
  | | `-- react@16.14.0 deduped
  | `-- react@18.2.0 deduped
  `-- react@18.2.0

Pretty obvious that there are 2 different react versions included:

  1. 16.14.0 for react-dom
  2. 18.2.0 for react

It looks like both packages are provided by the same forge/react dependency and a bit frustrated with it.

Any ideas of what I’m doing wrong to make it work? :frowning:

1 Like

Same here, came to see after I also upgraded and faced the same problem.

1 Like

seems like I just solved it, you should add "react": "^18.2.0" to our dependencies, und the error should be fixed. :wink:

3 Likes

Wow, you’re completely right, thanks, that helps! :partying_face:

But thought that this “react” package was already provided with forge/react 10.0.0

Because based on the dependencies - it should.

No luck unfortunately :tired_face: Adding React 18.2.0 to the dependencies obvs can’t do anything until I do npm install. But that fails, as it seems many of the Atlaskit components are on a React 16 version and incompatible with 18.2.0. Any ideas?

// “npm install” when react 18 is listed in the dependencies:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: confluence-global-page-custom-ui@1.0.42
npm ERR! Found: react@18.3.1
npm ERR! node_modules/react
npm ERR!   react@"^18.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0" from @atlaskit/button@17.14.2
npm ERR! node_modules/@atlaskit/button
npm ERR!   @atlaskit/button@"^17.14.2" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

When I do npm list react before react 18 is installed, I get the following

npm list react
npm ERR! code ELSPROBLEMS
npm ERR! invalid: react@16.14.0
confluence-global-page-custom-ui@1.0.42
+-- @atlaskit/button@17.14.2
| +-- @atlaskit/analytics-next@9.3.0
| | +-- @atlaskit/analytics-next-stable-react-context@1.0.1
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | `-- use-memo-one@1.1.3
| |   `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| +-- @atlaskit/ds-lib@2.3.1
| | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| +-- @atlaskit/focus-ring@1.4.0
| | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| +-- @atlaskit/icon@22.1.1
| | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| +-- @atlaskit/interaction-context@2.1.4
| | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| +-- @atlaskit/primitives@6.0.0
| | +-- @atlaskit/app-provider@1.3.1
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/css@0.1.0
| | | +-- @compiled/react@0.17.1
| | | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| +-- @atlaskit/spinner@16.1.0
| | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| +-- @atlaskit/theme@12.7.1
| | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| +-- @atlaskit/tokens@1.45.1
| | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| +-- @atlaskit/tooltip@18.3.0
| | +-- @atlaskit/motion@1.5.3
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/popper@5.5.5
| | | +-- react-popper@2.3.0
| | | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/portal@4.4.2
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- react-uid@2.3.3
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| +-- @atlaskit/visually-hidden@1.3.0
| | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| +-- @emotion/react@11.11.4
| | +-- @emotion/use-insertion-effect-with-fallbacks@1.0.1
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
+-- @atlaskit/dynamic-table@14.16.3
| +-- @atlaskit/pagination@14.6.6
| | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| +-- react-beautiful-dnd@12.2.0
| | +-- react-redux@7.2.9
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| +-- react-dom@16.14.0
| | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
+-- @atlaskit/lozenge@11.7.1
| +-- @atlaskit/ds-explorations@3.5.1
| | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
+-- @forge/react@10.1.0
| +-- @atlaskit/forge-react-types@0.5.6
| | +-- @atlaskit/badge@15.3.0
| | | +-- @atlaskit/primitives@5.7.0
| | | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/checkbox@13.3.0
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/code@15.1.2
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/form@9.3.1
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/heading@2.2.0
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/modal-dialog@12.13.2
| | | +-- @atlaskit/blanket@13.1.0
| | | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | | +-- @atlaskit/layering@0.3.0
| | | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | | +-- react-focus-lock@2.12.1
| | | | +-- react-clientside-effect@1.2.6
| | | | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | | | +-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | | | +-- use-callback-ref@1.3.2
| | | | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | | | `-- use-sidecar@1.1.2
| | | |   `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | | +-- react-scrolllock@5.0.1
| | | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/primitives@5.7.0
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/progress-bar@2.0.1
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/progress-tracker@8.5.9
| | | +-- @atlaskit/primitives@5.7.0
| | | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | | +-- react-transition-group@4.4.5
| | | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/radio@6.3.0
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/range@7.2.0
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/section-message@6.5.1
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/select@17.8.0
| | | +-- react-select@5.8.0
| | | | +-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | | | `-- use-isomorphic-layout-effect@1.1.2
| | | |   `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/tabs@14.1.0
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/tag-group@10.3.0
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/tag@12.2.1
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/textarea@5.4.0
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/textfield@6.3.0
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | +-- @atlaskit/toggle@13.0.5
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| +-- react-hook-form@7.51.4
| | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| +-- react-reconciler@0.29.2
| | `-- react@18.3.1 deduped
| +-- react-test-renderer@18.3.1
| | +-- react-shallow-renderer@16.15.0
| | | `-- react@16.14.0 deduped invalid: "^18.2.0" from the root project
| | `-- react@18.3.1 deduped
| `-- react@18.3.1
`-- react@16.14.0 invalid: "^18.2.0" from the root project

According to React peer dependency issue the atlaskit is stuck on React 16 for quite a while and might not change soon. So there is a broken dependency in this case.

You can try to use npm install --legacy-peer-deps to ignore this broken dependency and see if it works this way.

If it doesn’t you’d need to use the old UI Kit 1 (https://developer.atlassian.com/platform/forge/ui-kit-components/ui1-about/) and hope, atlaskit will be released in a newer version soon.