gpt4 book ai didi

javascript - 将 'connect' 与 React-Redux 相乘

转载 作者:行者123 更新时间:2023-12-03 05:02:59 26 4
gpt4 key购买 nike

我想一起使用react-redux和react-geolocated 。Booth 使用“命名”导出和默认导出

react-redux 连接人员

const mapStateToProps = (state) => {
return {
json: state.json
}
};

const mapDispatchToProps = (dispatch) => {
return {
someLocalMethod: () => dispatch(someRemoteMethod()),
}
};

export default connect(mapStateToProps, mapDispatchToProps)(Home)

react 地理定位相关连接人员

export default geolocated({
positionOptions: {
enableHighAccuracy: false,
},
userDecisionTimeout: 5000
})(Home);

如何将这两个导出合并在一起?

最佳答案

试试这个:

//file with geolocated stuff ------------------
...
export default geolocated({
positionOptions: {
enableHighAccuracy: false,
},
userDecisionTimeout: 5000
})(Home);

//file with react-redux connect stuff --------------
import geoHome from '/pathToGeolocatedHome';
...
export default connect(mapStateToProps, mapDispatchToProps)(geoHome)

关于javascript - 将 'connect' 与 React-Redux 相乘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42140625/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com