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?
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')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.