-
Notifications
You must be signed in to change notification settings - Fork 0
fix: npm install fails due to @testing-library/react-hooks peer dependency conflict #464
Copy link
Copy link
Open
Description
Hello!
I noticed that contributors using npm cannot install dependencies without using --legacy-peer-deps flag due to a peer dependency conflict with@testing-library/react-hooks.
Problem
Contributors using npm cannot install dependencies without using --legacy-peer-deps flag due to a peer dependency conflict with @testing-library/react-hooks.
Error with npm:
npm install
# npm ERR! ERESOLVE unable to resolve dependency tree
# npm ERR! Could not resolve dependency:
# npm ERR! peer react@"^16.9.0 || ^17.0.0" from @testing-library/react-hooks@8.0.1Warning with yarn:
yarn install
# warning " > @testing-library/react-hooks@8.0.1" has incorrect peer dependency "react@^16.9.0 || ^17.0.0".Root Cause
- This project uses React 18.3.1 for development
- This conflicts with the project's React 18.3.1, causing npm to block installation
- However, @testing-library/react@16.3.0 already includes renderHook API (available since v13.1)
Proposed Solution
- Remove from package.json:
"devDependencies": {
"@testing-library/react": "16.3.0",
- "@testing-library/react-hooks": "8.0.1",
...
}- Update imports in test files:
- import { renderHook } from '@testing-library/react-hooks';
+ import { renderHook } from '@testing-library/react';Affected files:
- src/use-countdown.test.tsx
- src/use-time.test.tsx
I'm happy to submit a PR for this if you'd like! 🙂
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels