【问题标题】:Using "connect" from Redux with react-css-modules使用 Redux 中的“连接”和 react-css-modules
【发布时间】:2017-02-04 03:46:32
【问题描述】:

到目前为止,我一直在使用 Redux "connect" 将组件与状态连接起来,我通过以下方式导出组件:

export default connect(mapStateToProps, actions)(ComponentTitle);

我现在想使用 react-css-modules,但我必须在每个组件中使用以下导出:

export default CSSModules(ComponentTitle, styles);

如何导出组件以同时具有这两种功能?

谢谢:)

【问题讨论】:

    标签: react-redux react-css-modules


    【解决方案1】:

    您可以在连接到 redux 之前使用 css 功能包装您的 react 组件。

    const ComponentWithCSS = CSSModules(ComponentTitle, styles);
    export default connect(mapStateToProps, actions)(ComponentWithCSS);
    

    【讨论】:

      猜你喜欢
      • 2018-10-06
      • 2018-04-08
      • 2018-04-04
      • 1970-01-01
      • 1970-01-01
      • 2019-08-11
      • 2017-10-10
      • 2019-09-05
      • 1970-01-01
      相关资源
      最近更新 更多