rgommezz / react-native-offline

Handy toolbelt to deal nicely with offline/online connectivity in a React Native app. Smooth redux integration ✈️
MIT License
2.34k stars 272 forks source link

Incompatible with react-redux v8 #357

Closed geraintwhite closed 1 year ago

geraintwhite commented 2 years ago

Current Behavior

Because react-redux is pinned to ^7.0.0 in dependencies it means that an application using react-native-offline is unable to use a newer major version of react-redux (e.g. v8) due to mismatched versions resulting in this issue.

$ npm ls react-redux
├─┬ react-native-offline@6.0.0
│ └── react-redux@7.2.8
└── react-redux@8.0.1
 ERROR  Error: Could not find "store" in the context of "Connect(ReduxNetworkProvider)". Either wrap the root component in a <Provider>, or pass a custom React context provider to <Provider> and the corresponding React context consumer to Connect(ReduxNetworkProvider) in connect options.

This error is located at:
    in Connect(ReduxNetworkProvider) (at app.js:103)
    in PersistGate (at app.js:102)
    in Provider (at app.js:101)
    in App
    in RCTView (at View.js:32)
    in View (created by b)
    in b
    in Unknown (at renderApplication.js:50)
    in RCTView (at View.js:32)
    in View (at AppContainer.js:92)
    in RCTView (at View.js:32)
    in View (at AppContainer.js:119)
    in AppContainer (at renderApplication.js:43)

Expected Behavior

The application should be able to use newer major versions of react-redux.

How to reproduce

Run app using react-native-offline 6.x and react-redux 8.x

Your Environment

software version
react-native-offline 6.0.0
react-native 0.68.1
node 16.14.0
npm 8.3.1
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

nilesh0710 commented 2 years ago

+1 facing the same issue

rgommezz commented 1 year ago

I've released v6.0.1. Please update to the latest, should be fixed now!

geraintwhite commented 1 year ago

This didn't actually fix the issue because "react-redux": "^7.0.0" is in the dependencies of react-native-offline, thus forcing this version to be included and conflicting with any other versions included by the app.

A workaround for app developers is to use the npm overrides feature with "react-redux": "$react-redux" to force the same version of react-redux throughout.

rgommezz commented 1 year ago

Good point.

I have decided to relax the constraints of dependencies, to mirror peer dependencies. I still prefer to have those dependencies and avoid people installing extra libraries, like react-redux in case they don't need it.

@grit96 v.6.0.2 is released. Let me know!

superyarik commented 7 months ago

@rgommezz hi, why 6.0.2 not listed in releases on github?