到目前为止,我一直在使用 Redux “connect” 将组件与状态连接起来,我通过以下方式导出组件:
export default connect(mapStateToProps, actions)(ComponentTitle);
我现在想使用react-css-modules,但我必须在每个组件中使用以下导出来完成此操作:
export default CSSModules(ComponentTitle, styles);
如何导出组件以具有这两种功能?
谢谢:)
最佳答案
在连接到 redux 之前,您可以使用 css 功能包装您的 React 组件。
const ComponentWithCSS = CSSModules(ComponentTitle, styles);
export default connect(mapStateToProps, actions)(ComponentWithCSS);
关于react-redux - 将 Redux 中的 "connect"与 react-css-modules 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39708938/