Jjang Jjang - 1 year ago 344
React JSX Question

Invalid prop children in Provider

I've been learning React for the past several weeks.

First developed a simple Chat with plain React, and now I started integrating Redux into my app.

I added a simple Action, a matching Reducer (along with a root reducer) and a Store.
I then reached the part where I need to use the Provider from the react-redux library:

import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { Router, browserHistory } from 'react-router';
import ConfigureStore from './Store/ConfigureStore';
import Routes from './Routes';

const store = ConfigureStore();
<Provider store={store}>
<Router history={browserHistory}
routes={Routes} />,

App compiles fine, but I receive the following errors in console:

Warning: Failed prop type: Invalid prop
of type
supplied to
, expected a single ReactElement.
in Provider


Uncaught Invariant Violation: React.Children.only expected to receive a single React element child.

I'm using the React Create App as a starter kit.

Full code can be found here.

Answer Source

You have a , after <Router history={browserHistory} routes={Routes} />

Try removing it?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download