React-redux: React 16. Invalid prop `children` of type `array` supplied to `Provider`, expected a single ReactElement.

Created on 9 Oct 2017  路  2Comments  路  Source: reduxjs/react-redux

As I understand it the Provider requires a single ReactElement as stated here https://github.com/reactjs/react-redux/issues/561

But with the release of React 16 React now supports returning arrays from render.

Are there any plans to update the Provider to support this feature? If not, why, is there some other reasoning behind this requirement?

Most helpful comment

As long as we continue to support older versions of React, we will need to have this restriction in place.

This generally isn't an issue because <Provider> is normally placed at the top of the tree and there is usually a single child under it, either another wrapper component (such as a router) or the base "App" or "Root" component for your application.

All 2 comments

As long as we continue to support older versions of React, we will need to have this restriction in place.

This generally isn't an issue because <Provider> is normally placed at the top of the tree and there is usually a single child under it, either another wrapper component (such as a router) or the base "App" or "Root" component for your application.

OK, thanks for the explanation. I understand, and agree that it's not the normal case to have something that returns an array directly within the Provider. And it's usually easy enough to work around it (just wrapping your array of React elements in an extra <div>...</div> for instance.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fuchsberger picture fuchsberger  路  3Comments

IbraheemAlSaady picture IbraheemAlSaady  路  3Comments

nainardev picture nainardev  路  3Comments

juangl picture juangl  路  3Comments

sajaddp picture sajaddp  路  3Comments