我有一个组件App.js,我尝试使用redux. 在 index.js 中,我只为<App />组件设置存储。
索引.js
let store = createStore(scoreReducer);
ReactDOM.render(
<Provider store={store}><App /></Provider>,
document.getElementById("root")
);
registerServiceWorker();
我有这个方法App.js可以将状态映射到内部可用的propsApp.js。
应用程序.js
function mapStateToProps(state) {
return { score: state.score, status: state.status };
}
到目前为止一切都很好,现在我不确定如何{ this.props.score}在另一个组件中访问?
index.js如果我想{this.props.score}在另一个组件中访问,我需要在第二个组件中做哪些更改?