jcoreio / material-ui-popup-state

boilerplate for common Material-UI Menu, Popover and Popper use cases
https://jcoreio.github.io/material-ui-popup-state/
MIT License
447 stars 28 forks source link

Error when building 5.3.0 with React 17 ('useId' is not exported from 'react') #138

Closed ryanadhi closed 2 weeks ago

ryanadhi commented 2 weeks ago

"material-ui-popup-state": "^5.3.0" "react": "17.0.2"

code

 <PopupState variant="popover" popupId="demoMenu">
            {popupState => (
                <ClickAwayListener onClickAway={(event) => popupState.close(event as any)}>
                  ...
                </ClickAwayListener>
            )}
</PopupState>

error

Failed to compile.

./node_modules/material-ui-popup-state/hooks.mjs
Attempted import error: 'useId' is not exported from 'react' (imported as 'React').
jedwards1211 commented 2 weeks ago

That's unfortunate, I had tried to make it only use useId if it's available...what bundler are you using?

ryanadhi commented 2 weeks ago

@jedwards1211 I am using Next 12.1.0, so I just use next build && next export. I believe it is using using Webpack

jedwards1211 commented 2 weeks ago

Okay thanks, I'll figure it out

jedwards1211 commented 2 weeks ago

:tada: This issue has been resolved in version 5.3.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

jedwards1211 commented 2 weeks ago

Okay this change fixed the issue in a Next 12.3.4 project for me (was having other problems figuring out how to downgrade the created project all the way to 12.1.0) but let me know if it fixes the issue for you

Edit: I downgraded to Next 12.1.0 and commented out some CSS imports, and I was able to get the build to pass

ryanadhi commented 2 weeks ago

@jedwards1211 yes I am able to build with 5.3.1. Thanks!

jedwards1211 commented 2 weeks ago

Great, yw!