Md.Feroj Ahmod Md.Feroj Ahmod - 8 months ago 33
React JSX Question

Change color of label in material-ui

I am trying change color of the subheader component. It only changes if i write like this

<subheader style={color.disabled} >Middle Name : </subheader>


where

const color = {
disabled: {
color: grey500,
},
};


I am trying to change the subheader color when changing state. How can i do that?

Answer Source

Unless I'm misunderstanding the question, there doesn't seem to be any more to this than standard use of state:

changeSubheader() {
  this.setState(
    subheaderDisabledColor: {
      disabled: {
        color: red500,
      },
    };
  );
};

<subheader style={this.state.subheaderDisabledColor}>Middle Name : </subheader>

https://facebook.github.io/react/docs/state-and-lifecycle.html#using-state-correctly