Skip to content

Dependency Conflict: react-native requires React 19, throwing a warning with React 18 Projects #5

@esitarz

Description

@esitarz

Description

@ordercloud/react-sdk uses @react-native-async-storage/async-storage@2.1.2 to persist TanStack query state.
This package pulls in react-native@0.78.0, which has a strict peerDependency on react@"^19.0.0".
React 18 apps cannot satisfy this dependency without risking compatibility or overriding constraints via --legacy-peer-deps or patching.

Steps to Reproduce:

  1. Set up a project using React 18 and @ordercloud/react-sdk.
  2. Delete package-lock.json and node_modules.
  3. Run npm install.
  4. Observe ERESOLVE or peer dependency warnings related to react-native expecting React 19.

Here's my example in Accelerator storefront:

npm WARN While resolving: react-native@0.78.0
npm WARN Found: react@18.3.1
npm WARN Could not resolve dependency:
npm WARN peer react@"^19.0.0" from react-native@0.78.0
npm WARN node_modules/@ordercloud/react-sdk/node_modules/react-native
npm WARN   peer react-native@"^0.0.0-0 || >=0.65 <1.0" from @react-native-async-storage/async-storage@2.1.2
npm WARN   node_modules/@ordercloud/react-sdk/node_modules/@react-native-async-storage/async-storage
npm WARN   1 more (@react-native/virtualized-lists)
npm WARN 
npm WARN Conflicting peer dependency: react@19.0.0
npm WARN node_modules/react
npm WARN   peer react@"^19.0.0" from react-native@0.78.0
npm WARN   node_modules/@ordercloud/react-sdk/node_modules/react-native
npm WARN     peer react-native@"^0.0.0-0 || >=0.65 <1.0" from @react-native-async-storage/async-storage@2.1.2
npm WARN     node_modules/@ordercloud/react-sdk/node_modules/@react-native-async-storage/async-storage
npm WARN     1 more (@react-native/virtualized-lists)

Possible Solutions

1. Refactor react-native storage:

  • Refactor the SDK’s query.ts file to use browser-native localStorage or a storage that uses async-storage.
  • This removes the need for @react-native-async-storage/async-storage and react-native entirely.

2. Lock the version

  • Lock @react-native-async-storage/async-storage to 2.0.x, which does not have a strictly require react 19.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions