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 1382 times
Edit
1
Community EvaluationsNo one has reviewed this question yet, be the first!
Similar QuestionsMore questions about React