Missing peerDependencies for react and react-native causes duplicate React instances in pnpm monorepos
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 68/100
Research direction
Start with the slider package's package.json and inspect how its dependencies are declared. Add the requested peer dependency declarations, then verify the pnpm monorepo reproduction no longer resolves a separate React instance and avoids the invalid hook call.
Written by the indexing model from the issue text.
Description
Environment
- react-native info output:
react-native: 0.81.5
react: 19.1.0
expo: 54.0.33
@react-native-community/slider: 5.1.2
-
are you using the new architecture?
Yes -
which version of react & react-native are you using?
React 19.1.0, React Native 0.81.5
Description
@react-native-community/slider does not declare react or react-native in its peerDependencies. This causes duplicate React instances in pnpm monorepos with strict dependency isolation, resulting in the classic "Invalid hook call" runtime error.
Root cause
The slider package uses React internally (hooks, JSX) but its package.json has no peerDependencies field. In pnpm monorepos without nodeLinker: hoisted, each package only sees its own declared dependencies. Since pnpm doesn't know the slider needs React, it doesn't link the host app's React to the slider. At runtime, the slider resolves a different React copy from pnpm's internal store, causing two React instances in the same app.
Error
ERROR Invalid hook call. Hooks can only be called inside of the body of a function component.
This could happen for one of the following reasons:
- You might have mismatching versions of React and the renderer (such as React DOM)
- You might be breaking the Rules of Hooks
- You might have more than one copy of React in the same app
Workaround
Adding packageExtensions in the root package.json fixes it:
{
"pnpm": {
"packageExtensions": {
"@react-native-community/slider": {
"peerDependencies": {
"react": "*",
"react-native": "*"
}
}
}
}
}
Suggested fix
Add peerDependencies to the slider's package.json:
"peerDependencies": {
"react": "*",
"react-native": "*"
}
This is consistent with how other React Native libraries declare their peer dependencies (e.g. react-native-reanimated, react-native-gesture-handler, @gorhom/bottom-sheet).
Reproducible Demo
Create a pnpm monorepo with two apps (e.g. a Next.js web app using React 19.2.x and a React Native app using React 19.1.0)
Do not use nodeLinker: hoisted in pnpm-workspace.yaml (pnpm's default strict isolation)
Install @react-native-community/slider in the React Native app
Use the component
The app crashes at runtime with "Invalid hook call" because the slider resolves a different React instance from pnpm's .pnpm/node_modules/react
- Dominant language
- TypeScript
- Stars
- 1.4k
- Forks
- 295
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from callstack/react-native-slider
-
bug report platform: iOS
Difficulty 4/5 3-5 days Newbie friendliness 42/100
callstack/react-native-slider#782 · 6 comments ·
-
bug report
Difficulty 3/5 1-2 days Newbie friendliness 65/100
callstack/react-native-slider#780 · 1 comment ·
-
bug report
Difficulty 3/5 1-2 days Newbie friendliness 35/100
callstack/react-native-slider#767 ·
-
bug report platform: iOS
Difficulty 4/5 3-5 days Newbie friendliness 45/100
callstack/react-native-slider#758 · 4 comments ·
-
bug report
Difficulty 4/5 3-5 days Newbie friendliness 35/100
callstack/react-native-slider#745 · 3 comments ·
All issues in callstack/react-native-slider
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
copse-dev/agent-pane#2953 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·