Skip to content

fix: npm install fails due to @testing-library/react-hooks peer dependency conflict #464

@JeanYoungPark

Description

@JeanYoungPark

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.1

Warning 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

  1. Remove from package.json:
"devDependencies": {
    "@testing-library/react": "16.3.0",
-   "@testing-library/react-hooks": "8.0.1",
     ...
  }
  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! 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions