Currently diving into a new React.js project as a beginner. I have a little challenge in the code snippet below - looking to add a button that displays "Hello World" every time it's clicked using setState. Can anyone guide me on enhancing the DisplayMethod() function?
class MessageDisplayed extends React.Component {
constructor(props) {
super(props);
this.state = {message: "Hello World"};
this.DisplayMessage = this.DisplayMessage.bind(this);
}
DisplayMessage() {
this.setState(state => ({
//Need assistance in adding more "Hello World" buttons each time it's clicked.
}))
}
render(){
return (
<button onClick={this.DisplayMessage}><h1>{this.state.message}</h1></button>
)
}
}
ReactDOM.render(
<MessageDisplayed />,
document.getElementById("root")
);