如何将 Redux 连接到比父组件低几层的子组件?我不知道如何在store
不爆炸的情况下进入道具。
我没有使用 IronRouter,而是使用带有 React 0.13 的 Redux 3。这是一个例子:
const SearchBar = React.createClass({
render() {
return <div> {this.props.text} </div>;
}
});
function mapStateToProps(state) {
return {text: state.search.text};
}
_SearchBar = connect(mapStateToProps)(SearchBar);
在“连接(搜索栏)”的上下文或道具中找不到“商店”。要么将根组件包装在 a 中
<Provider>
,要么将“store”作为道具显式传递给“Connect(SearchBar)”。