I'm using react and I have some methods to set the state of my COmponent separately. I have the following methods:
setLineColor(value){
this.setState({stroke:value},()=>{
this.props.data(this.getStyleData());
});
}
setFillColor(value){
this.setState({ fill:value},()=>{
this.props.data(this.getStyleData());
});
}
setMode(value){
this.setState({ mode:value},()=>{
this.props.data(this.getStyleData());
});
}
How can I combine the methods, so that I can have something like:
setAttribute(propery,value){...}
?
Like this
setAttribute(property, value) {
this.setState({ [property]: value }, () => {
this.props.data(this.getStyleData());
});
}
Example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With