I’m stuck on the the following exercise:
Call this.setState from Another Function
- Before the render method, give Toggle a constructor() method. Toggle’s constructor() method should have one parameter, named props.
Inside the body of the your constructor method, call super(props); On a new line, still inside the body of your constructor method, set this.state equal to this object: { color: green }. Use the example as a guide.
The step 1 instructions keeps turning red when I try to run but I’m not getting an error and I’m blind to what I’m missing in order to move to step 2.
Please help?
import React from 'react';
const green = '#39D1B4';
const yellow = '#FFD712';
class Toggle extends React.Component {
constructor(props){
super(props);
this.state = { color: green };
}
render() {
return (
<div>
<h1>
Change my color
</h1>
</div>
);
}
}