用createProvider替换redux provider会引发错误

时间:2019-08-11 18:27:43

标签: javascript reactjs redux react-redux

我有一个带有上下文提供程序的系统,该系统可以在一个商店中正常工作

import { connect, Provider } from 'react-redux'
import sfc from './component'

const mapStateToProps = (state, ownProps) => ({
    host: ownProps.host
})

const ConnectedSfc = connect(mapStateToProps)(sfc)
export const AppMainView = props => (
    <Provider store={props.host.getStore()}>
        <ConnectedSfc host={props.host} />
    </Provider>
)

现在我正在尝试将我的工作区设置为处理两个不同的商店,
因此,我根据this指南更改了提供程序:

import { connect, createProvider } from 'react-redux'
import sfc from './component'
import { STORE_KEY } from './constants'

const Provider = createProvider(STORE_KEY)

然后将storeKey设置为连接选项。

但是,当我运行项目时(只有很小的更改),就会引发错误:

Uncaught Invariant Violation: Could not find "store" in either the context or props of "Connect(sfc)".
Either wrap the root component in a <Provider>, or explicitly pass "store" as a prop to "Connect(sfc)".

我在做什么错了?

0 个答案:

没有答案