首页 > 代码库 > react-redux知识点

react-redux知识点

1.定义组件;

2.定义action;

3.定义Reducer:reducer1(state,action);

4.定义store:store(reducer1);

5.定义mapStateToProps(state);

6.定义mapDispatchToProps(dispatch);

7.定义connect:

const App = connect(
    mapStateToProps,
    mapDispatchToProps
)(组件);

8.渲染元素:

ReactDOM.render(
    <Provider store={store}>
        <App />
    </Provider>,
    document.getElementById(‘page‘)
);

 

react-redux知识点