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),该怎么做?
答案 0 :(得分:0)
只需将其添加为您的CTreeCtrl
方法的一部分:
mapStateToProps