react-redux - 将 Redux 中的 "connect"与 react-css-modules 一起使用

标签 react-redux react-css-modules

到目前为止,我一直在使用 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/

相关文章:

javascript - 将 Flowtype 与 react-css-modules 装饰组件一起使用

selenium - 使用 Selenium 的 CSS 模块?

reactjs - 通过 id 重新选择 createSelector

reactjs - 在两个 reducer 之间共享状态

css - 样式不适用于使用 react-css-modules

javascript - 通过 webpack 构建的 Typescript 在 React 组件中使用 CSS 模块

reactjs - Ant 设计 : modify border-radius for Input component

javascript - 语法 高阶组件 - Autosizer

javascript - 流类型操作确实适用于对象引用

javascript - 以 redux-form 形式添加多个 <Fields/>