首页 > 解决方案 > material-ui withStyle 不适用于 resux-form

问题描述

我目前正在开发我的第一个真正的 React-Redux 应用程序(准确地说是 ReactDom)。该应用程序正在使用材质 ui(我不是项目经理)

我无法将样式应用于通过 reduxForm 导出的组件。我的代码:

import React, {Component} from 'react';
import {withStyles} from '@material-ui/core/styles/withStyles';
import { TextField } from '@material-ui/core';
import { Field, reduxForm} from 'redux-form';
import {connect} from 'react-redux';
import { some acttions } from '../actions';


const styles = (theme) => ({});

const mapStateToProps = (state) => ({});

const mapDispatchToProps = (dispatch) => ({
    some: () => dispatch(some(data)),
    actions: () => dispatch(actions())
})


class FormComponent extends Component {
// Component with form
}

FormComponent = connect(
    mapStateToProps,
    mapDispatchToProps
)(withStyles(styles)(FormComponent));

export default reduxForm({
    form: 'myForm'
})(FormComponent);

这导致TypeError: Object(...) is not a function指向带有连接的命令。当我用Style擦除时,它不会损坏,但看起来很糟糕。

提前致谢, 加尔

标签: reduxmaterial-uiredux-form

解决方案


推荐阅读