Skip to content Skip to sidebar Skip to footer

React Set State Property Dynamically

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},()=>{ th

Solution 1:

Like this

setAttribute(property, value) { 
  this.setState({ [property]: value }, () => {
    this.props.data(this.getStyleData());
  });
}

Example

Post a Comment for "React Set State Property Dynamically"