Invariant Violation with Redux connected components
I'm hitting an Invariant Violation error that goes like this:
Invariant Violation: Could not find "store" in the context of "Connect(ConnectedSubComponent)". 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(ConnectedSubComponent) in connect options.
I've noticed that this only happens when using react-redux connect() to connect a component into redux store and placing this as the child component in the popup dialog.
I reproduced the error for you to take a look at here: https://github.com/tuomohopia/reduce-fail
Am I using this library the correct way or is this an actual bug that is discovered?
I'm using Android with emulator.
Versions:
- Windows 10
- node v10.15.3
- react-native-popup-dialog 0.17.0
- react-native v0.59.2
- redux 4.01
- react-redux 6.01
The relevant code is in the App.js file:
https://github.com/tuomohopia/reduce-fail/blob/master/App.js
Otherwise it's just a react-native init bootstrapped setup.
For the record, I'm still experiencing this issue in the just released version 0.18.2
I believe I have a similar issue.
I have a component using context api in HOC, I place this component inside
@atominvention did you try if the problem persists with the just released react-redux version of 7.0.1?
I'm still experiencing this at react-redux v.7.0.2.
Just having this issue too after upgrading react-native-popup-dialog from 0.10.46 to 0.18.2.
Versions: react-native-popup-dialog 0.18.2 react-native v0.59.2 redux 4.01 react-redux 7.0.2
I am having the same issue, any workaround?
This problem still seems to persist, pls fix
Also facing this issue :(
I'm currently facing this issue too. No one has solved it?
I'm having the same issue
We resorted to using React Native Elements Overlay, which basically handles the same but without any problems. Before we used to pass the relevant redux store items manually as props to the component.
Same problem with:
react-native-popup-dialog 0.18.3 react-native v0.61.4 redux 4.0.4 react-redux 7.1.3
This is most likely caused by React Native Modals not supporting the new React Context API. Can anyone verify this is the reason?
I am also affected by this issue. Tried to inject the store inside the dialogue using ReactReduxContext but that also didn't work. So I think you might be right @CoenWarmer
The workaround is to wrap the content inside the modal, with a provider that consumes the relevant reducers. I overcame the problem with this method. The example is as below:
// the reducers contain the one that the component inside the modal targets
const store = createStore(reducers, {}, applyMiddleware(ReduxThunk));
<Modal
visible={this.state.modalState}
onDismiss={() => {
...
}}
onTouchOutside={() => {
this.setState({modalState: false});
}}
onHardwareBackPress={() => {
this.setState({modalState: false});
return true;
}}>
<Provider store={store}>
<View>
// the content
</View>
</Provider>
</Modal>
We still need a solution for this.
This problem has been resolved in version v0.20.1