Redux开发工具嵌入提供程序和路由器时失败
我正在按照Redux教程创建Todo应用程序,并尝试在我的Redux开发工具嵌入提供程序和路由器时失败,redux,react-redux,redux-devtools,Redux,React Redux,Redux Devtools,我正在按照Redux教程创建Todo应用程序,并尝试在我的提供商旁边的React Router下应用和嵌入它,但我遇到了以下错误: Warning: Failed prop type: Invalid prop `children` of type `array` supplied to `Provider`, expected a single ReactElement. in Provider (created by Root) in Root 以下是我尝试嵌入它的方式:
提供商
旁边的React Router
下应用和嵌入它,但我遇到了以下错误:
Warning: Failed prop type: Invalid prop `children` of type `array` supplied to `Provider`, expected a single ReactElement.
in Provider (created by Root)
in Root
以下是我尝试嵌入它的方式:
import { createStore } from 'redux'
import todos from './reducers'
import DevTools from './components/DevTools'
const store = createStore(todos, {}, DevTools.instrument())
const Root = ({ store }) => (
<Provider store={store}>
<Router history={browserHistory}>
<Route path="/(:filter)" component={App} />
</Router>
<DevTools /> <!-- If I remove DevTools everything is fine -->
</Provider>
)
Root.propTypes = {
store: PropTypes.object.isRequired
}
render(<Root store={store} />, document.getElementById('app'))
为了以防万一,这对任何人都有帮助,我保留这个问题。因此,我通过将
与
组件相邻并将其传递到存储中来解决这个问题
const Root = ({ store }) => (
<Provider store={store}>
<Router history={browserHistory}>
<Route path="/(:filter)" component={App} />
</Router>
</Provider>
{!isProduction && <DevTools store={store} /> }
)
constroot=({store})=>(
{!i生产&&}
)
此外,我还指出,如果代码库是用于生产的,如果不是,则显示
组件,这是因为当您构建应用程序时,Redux开发工具不会包含在您的应用程序的大部分中。为了以防万一,我保留这个问题。因此,我通过将
与
组件相邻并将其传递到存储中来解决这个问题
const Root = ({ store }) => (
<Provider store={store}>
<Router history={browserHistory}>
<Route path="/(:filter)" component={App} />
</Router>
</Provider>
{!isProduction && <DevTools store={store} /> }
)
constroot=({store})=>(
{!i生产&&}
)
我还指出,如果代码库是用于生产的,如果不是,则显示
组件,这样在构建应用程序时,Redux开发工具就不会包含在应用程序的大部分中