React Redux Tutorials - 17 - Store
Create a redux store and provide it to our react application.
src / redux / store.js
import { createStore } from 'redux';
import cakeReducer from './cake/cakeReducer';
const store = createStore(cakeReducer);
export default store
To provide this store to our react application, react-redux library exports a component called Provider
.
src / App.js
import React from 'react';
// import the Provider and the store
import { Provider } from 'react-redux';
import store from './redux/store'
import CakeContainer from './components/CakeContainer';
function App() {
return (
<Provider store={store}>
<div className="App">
<CakeContainer />
</div>
</Provider>
);
}
export default App;
On the Provider
component, we can specify a prop called store
and pass in the store
that we have imported.
Typically, we provide store at the top of the app. App.js
Author And Source
이 문제에 관하여(React Redux Tutorials - 17 - Store), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@jheeju/React-Redux-Tutorials-17-Store저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)