I am learning redux
to manage state of the application. I am going through official docs http://redux.js.org for it.
I gotcha use of redux
but in the usecase they have placed <App />
inside <Provider>
. Can anyone suggest me what <Provider>
do ?
import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'react-redux'
import { createStore } from 'redux'
import todoApp from './reducers'
import App from './components/App'
let store = createStore(todoApp)
render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root')
)
In their git repository, they provide a description of what the <Provider>
is and how it's used, please see the link
Basically, the <Provider>
enables the redux store for the application. So you can connect
your containers to the store
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.