I am a newbie in REACT. I created a form with a few components. In one of the components, I have a checkbox and a paragraph with text in it. I can't figure out how to hide the paragraph when the checkbox is clicked. The boolean is captured in state but not sure how to use it to do what I want.
class Anonymous extends React.Component{
constructor(){
super();
this.state = {
anon:false
}
this.anonymousBox = this.anonymousBox.bind(this)
}
anonymousBox(event){
this.setState({anon:event.target.checked})
}
render(){
return(
<span>
<input type="checkbox"
name="anon" value=""
onChange={this.anonymousBox}
checked={this.state.anon}
/> Anonymous
<p style={{backgroundColor:'yellow'}}>
First Name: <br />
Last Name: <br />
Email: <br />
Country: <br />
Phone: <br />
</p>
</span>
)
}
}