Medium
class ColorName extends React.Component{
    constructor(props){
        super(props);
        this.colorByCode={
           "#ff0000":"red",
           "#00ff00":"green",
           "#0000ff":"blue",
        };
    }
    
    render(){
        return(<span>{this.colorByCode[this.props.colorCode]}</span>);
    }
}
ColorName.propTypes={
    colorCode: PropTypes.string.isRequired
};
Check the valid proposal(s):
Author: Victor SabatierStatus: PublishedQuestion passed 1542 times
Edit
2
Community EvaluationsNo one has reviewed this question yet, be the first!
7
Optimize a React component by implementing shouldComponentUpdate7
How to submit a form in React6
Write a React function that fetches comments and passes them to a component.7
Improve this React component so that it displays "Green" by default.3
Fix the following React component: Scroller3
Write the missing code to render the children of the UserProfile component.3
Write a React component as a function