grommet / grommet

a react-based framework that provides accessibility, modularity, responsiveness, and theming in a tidy package
https://grommet.io
Apache License 2.0
8.31k stars 1.02k forks source link

React 18.3.1 w/ grommet useState fails #7228

Open Aubrey-Russell opened 2 weeks ago

Aubrey-Russell commented 2 weeks ago

Updating to react 18.3.1 breaks grommetjs

Expected Behavior

It should work normally

Actual Behavior

Uncaught TypeError: Cannot read properties of null (reading 'useState') at useState (react.development.js:1622:1) at Grommet.js:53:27 at renderWithHooks (react-dom.development.js:15486:1) at updateForwardRef (react-dom.development.js:19245:1) at beginWork (react-dom.development.js:21675:1) at HTMLUnknownElement.callCallback (react-dom.development.js:4164:1) at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:1) at invokeGuardedCallback (react-dom.development.js:4277:1) at beginWork$1 (react-dom.development.js:27490:1) at performUnitOfWork (react-dom.development.js:26596:1)

URL, screen shot, or Codepen exhibiting the issue

image

Steps to Reproduce

Install grommet 2.37.0 with react 18.3.1

Your Environment

VS code react application with grommetjs

jcfilben commented 2 weeks ago

I tried to reproduce the issue in this codesandbox but wasn't getting an error. Let me know if there is anything I should adjust in my codesandbox to be able to reproduce the issue.

Aubrey-Russell commented 2 weeks ago

@jcfilben thank you very much for checking, I am attempting to replicate it on my end on a fresh repo so I will post here if I am able to. We are running a complex micro front end environment so its possible something specific to our project is leading to an unexpected interaction. Thanks again!

Aubrey-Russell commented 2 weeks ago

Hi, I managed to replicate it here at this repo and will try to import into code sandbox as well:

https://github.com/Aubrey-Russell/grommet-react-mfe-issue-example

This is using nx nrwl as a framework for context:

image

jcfilben commented 2 weeks ago

Thanks for putting together the sample repo, I cloned it and ran nx serve mfe-ex-1 but didn't see any errors in the console. For more context I'm using pnpm v8.7.6. Also I haven't used nx before so not sure if I'm missing anything there or running things incorrectly

Aubrey-Russell commented 2 weeks ago

@jcfilben Hi, sorry I thought I had included instructions in the readme but I did not.

Please run pnpm nx serve shell. I have also created the issue in the nx nrwl repo .