我正在创建一个既依赖于react-redux的connect又依赖于google-maps-react的GoogleAPIWrapper的组件,并且我在弄清楚如何使用这两种方法导出我的类时遇到了麻烦。
下面是我的connect导出的样子:
export default connect(mapStateToProps, mapDispatchToProps)(MapContainer);下面是我的GoogleAPIWrapper导出的样子:
export default GoogleApiWrapper({
apiKey: 'xxxxxxxxxxxxxxxxxxx'
})(MapContainer);如何同时使用这两个组件进行导出?
发布于 2019-12-27 07:10:57
你可以这样做:
export default GoogleApiWrapper({
apiKey: 'xxxxxxxxxxxxxxxxxxx'
})(connect(mapStateToProps, mapDispatchToProps)(MapContainer));或者像这样:
const connector = connect(mapStateToProps, mapDispatchToProps)(MapContainer);
export default GoogleApiWrapper({
apiKey: 'xxxxxxxxxxxxxxxxxxx'
})(connector);https://stackoverflow.com/questions/59493133
复制相似问题