React and Redux: Use Provider to Connect Redux to React - "Provider takes 2 props"?

In this lesson it says

Provider takes two props, the Redux store and the child components of your app

However in the example below it only shows it taking in 1 prop - the store.

<Provider store={store}>

In the subsequent instructions for the challenge, it looks like we only pass in 1 prop to Provider as well - the store:

Use this top level component to render the Provider from ReactRedux , and pass the Redux store as a prop

I tried looking around online as well and it looks like only 1 prop is ever passed to Provider in the examples I saw.

Is the second prop mentioned optional perhaps? If so, in what cases would we need/want to pass it in?

Thanks in advance!

It looks like there is an optional 2nd prop you can provide according to the documentation on the following page: Provider | React Redux

You may provide a context instance. If you do so, you will need to provide the same context instance to all of your connected components as well.

Note that it is not common to provide the 2nd prop though.

I see, so I guess the “context instance” referred to in that documentation is what the lesson refers to as “child components”? They kind of sound like very different things to me. Do you know how that second prop might look? An array I guess?

Honestly, I have never seen anything beside the store being used as the prop, but you can see an example on the bottom of the page I linked:

<Provider store={clientStore} serverState={preloadedState}>
    <App />

I see, fair enough. Thanks!

Technically children is a prop.

Which is why you can do this.

function App() {
  return (
      <Paragraph />

function Container({ children }) {
  return <section class="container">{children}</section>;

function Paragraph() {
  return <p>I should be inside a container</p>;

export default App;
1 Like

Oh interesting, this is good to know. Thank you!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.