facebookarchive / redux-react-hook

React Hook for accessing state and dispatch from a Redux store
MIT License
2.16k stars 103 forks source link

Would it be possible to use redux-form with StoreContext.Provider from redux-react-hook? #87

Closed sainiankit closed 4 years ago

sainiankit commented 4 years ago

The following code results in: Invariant Violation: Could not find "store" in the context of "Connect(t)". Either wrap the root component in a , or pass a custom React context provider to and the corresponding React context consumer to Connect(t) in connect options.

import {StoreContext} from 'redux-react-hook';
.
.
<StoreContext.Provider value={store}>
    <ReduxFormComponent />
</StoreContext.Provider>

However, this works fine.

import { Provider } from 'react-redux';
import {StoreContext} from 'redux-react-hook';
.
.
const store = useContext(StoreContext);

<Provider store={store}>
    <ReduxFormComponent />
</Provider>

redux-form seems to depend on react-redux's Provider. What would be the best way around this?

ianobermiller commented 4 years ago

If you want to use both react-redux and redux-react-hook, you need both of their providers.