Easy
We want to improve this component so that it displays"Green"by default.
class CSSColors extends React.Component{
  constructor(props){
    super(props);
    this.state={colorCode: ''};
    this.changeColor= this.changeColor.bind(this);
  }
  
  changeColor(evt){
    this.setState({colorCode: evt.target.value});
  }
  
  render(){
    return(
     <div>
        The color code
       <select onChange={this.changeColor}>
         <option value="#ff0000">Red</option>
         <option value="#00ff00">Green</option>
         <option value="#0000ff">Blue</option>
       </select>
        is{this.state.colorCode}
     </div>
    );
  }
}
How to do ?
Author: Victor SabatierStatus: PublishedQuestion passed 1489 times
Edit
7
Community EvaluationsNo one has reviewed this question yet, be the first!
3
Fix the following React component: Scroller6
Write a React function that fetches comments and passes them to a component.2
Fix the following React component:3
Write the missing code to render the children of the UserProfile component.3
Write a React component as a function7
Optimize a React component by implementing shouldComponentUpdate7
How to submit a form in React