设置材料UI的初始值复选框

时间:2018-11-08 04:17:02

标签: reactjs redux react-redux material-ui redux-form

    function mapStateToProps(state) {
        return {
                  model: Selectors.Quotes.getCurrentQuote(state),

        };
    }

    class Customer extends Component {
        state = {
            checkedEnergyConcessionHolder: false

        };

        handleChange = name => event => {
            this.setState({ [name]: event.target.checked });
        };

        render() {
            const { model} = this.props;
            const { checkedEnergyConcessionHolder  } = this.state;
            return (
                            <Checkbox>
                                label="Concession holder"
                                value="checkedEnergyConcessionHolder"
                                checked={checkedEnergyConcessionHolder}
                                onChange={
                                    this.handleChange('checkedEnergyConcessionHolder')
                                }
                            </Checkbox>
            );
        }
    }

    export default withStyles(panelTheme)(connect(mapStateToProps)(Customer));

如何初始化复选框的值?我需要默认值来自模型(等于model.EnergyConcessionHolder),该怎么做?

1 个答案:

答案 0 :(得分:0)

只需将其添加为您的CTreeCtrl方法的一部分:

mapStateToProps