Advertisements

React add conditional class

Advertisements

react add conditional class

style.css

.valid {
  color: green;
}

.error {
  color: red;
}
import style from '/css/style.css';

component

<input className={`form-control round-lg ${this.state.valid ? style.valid : style.error}`} />

click for more React codes, read about react style