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

Incompatibility of resize-observer with Nextjs 12. #172

Open
sotirelisc opened this issue Dec 31, 2021 · 6 comments
Open

Incompatibility of resize-observer with Nextjs 12. #172

sotirelisc opened this issue Dec 31, 2021 · 6 comments

Comments

@sotirelisc
Copy link

Describe the bug
We have updated our project to Next 12 and the following appears when we load a page with a component that uses resize-observer.
SyntaxError: The requested module 'react' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export. For example: import pkg from 'react'; const {useRef: r,useEffect: t}from"react";export default e=>{var a=r(e);return t(()=>{a.current=e}),a} = pkg;

To Reproduce
Steps to reproduce the behavior:

  1. Use resize-observer
  2. Update to Next 12

Screenshots
Screenshot 2021-12-31 at 09 17 15

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Chrome Version 96.0.4664.110
  • @react-hook/resize-observer Version: 1.2.5
  • next Version: 12.0.7
@jaredLunde
Copy link
Owner

Not clear to me this is my issue vs. Next's

@sotirelisc
Copy link
Author

Not clear to me this is my issue vs. Next's

Hello, it's not clear to me either. Have you maybe tried to reproduce it?

@jaredLunde
Copy link
Owner

I'm using other hooks in this group that use the same package.json configurations and import React with Next 12.0.7 and haven't run into any issues so far 🤷🏼‍♂️

@mt-deva
Copy link

mt-deva commented May 31, 2022

I'm getting this - NextJS@12^ but it only throws in my Jest@28 tests

@ajubin
Copy link

ajubin commented Nov 9, 2022

Hi, it may be late, but for future user encountering this issue, I found a fix.

This is the same as here react-hook-form/resolvers#396 (comment)

But instead filter out the pkg this way

    if (typeof pkg.name === 'string' && pkg.name.startsWith('@react-hook/')) {
        delete pkg['exports'];
        delete pkg['module'];
      }

@ricovitch
Copy link

Solved it for me. I'm not using next, but had this issue while migrating to jest28 and 29 in a react library project.

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

No branches or pull requests

5 participants