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();
ReactDOM.render(
<Provider store={store}>
<Router history={browserHistory}
routes={Routes} />,
</Provider>,
document.getElementById('root')
);
App compiles fine, but I receive the following errors in console:
Warning: Failed prop type: Invalid prop
children
of typearray
supplied toProvider
, expected a single ReactElement. in Provider
and
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.
You have a ,
after <Router history={browserHistory} routes={Routes} />
Try removing it?
The same error:
Warning: Failed prop type: Invalid prop
children
of typearray
supplied toProvider
, expected a single ReactElement.Uncaught Error: React.Children.only expected to receive a single React element child.
Occurs to me in writing Provider with this format:
<Provider store={store}> <App4Connected /> </Provider>
instead the following works correctly:
<Provider store={store}>
<App4Connected />
</Provider>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With