jaredLunde / jaredLunde/react-hook
Incompatibility of resize-observer with Nextjs 12.
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 96
- PR merge metrics
- No merged PRs in 30d
Description
**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**

**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
Contributor guide
Research direction
Reproduce the failure with Next 12.0.7 and @react-hook/resize-observer 1.2.5 using a page containing a resize-observer component. Inspect the package's published module imports and React interoperability; done means the page loads without the reported CommonJS named-export syntax error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100