I have Message.js -
import React from 'react';
import { Button } from 'reactstrap';
class Message extends React.Component
{
constructor()
{
super()
this.state={
message:"This is message"
}
}
changeMessage() {
alert("In");
this.setState({
message :"message changed"
});
}
render=()=> {
return <div>
<h1>{this.state.message}</h1>
<Button onClick="{this.changeMessage}" color="success">success</Button>
</div>
}
}
export default Message
Button click is not working here. I tried with -
<Button onClick={changeMessage} color="success">success</Button>
Then Also Tried -
<Button onClick="changeMessage()" color="success">success</Button>
This also did not work.
Uncaught TypeError : this.props.onClick is not a function.
