Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding React-Redux to a React app with React.StrictMode tag

The latest create-react-app has <React.StrictMode> tags wrapped around the component by default. Every example I see that adds react-redux to an application does not have React.StrictMode tags in it.

Here is what I have done:

<Provider store={store}>
  <React.StrictMode>
    <App />
  </React.StrictMode>
</Provider>,
document.getElementById('root')

However, I am always seeing:

<Provider store={store}>
  <App />
</Provider>,
document.getElementById('root')

I read up on what StrictMode is used for. I think it helps with debugging and giving insight on problems within the app so I want to keep it when developing. Is what I did correct or should Provider completely replace it like in all of the examples?

like image 614
Blake Rivell Avatar asked Dec 06 '25 06:12

Blake Rivell


1 Answers

React.StrictMode should wrap the whole application including the provider too. So Change your code like bellow:

From

  <Provider store={store}>
    <React.StrictMode>
      <App />
    </React.StrictMode>
  </Provider>,
  document.getElementById('root')

To

  <React.StrictMode>
    <Provider store={store}>
      <App />
    </Provider>
  </React.StrictMode>,
  document.getElementById('root')
like image 95
Arnab Avatar answered Dec 08 '25 21:12

Arnab



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!