Here is my react code. I seen several examples for calling a function and I am having no luck. I have my app.js folder rendering the NavigationDiv to HTML in a separate folder, everything is displaying even the button but when I click on it nothing happens.
This was a close post to mine: React events not firing but mine still is not firing. If I put {this.fireEvent()} I can get it to fire once but not again. Thank you in advance!
var React = require('react');
var NavigationDiv = React.createClass({
getInitialState: function()
{
return {liked: false};
},
handleClick: function(event)
{
this.setState({
liked: !this.state.liked
});
},
fireEvent:function()
{
console.log("am i being clicked" );
},
render: function()
{
var text = this.state.liked ? 'like' : 'haven\'t liked';
return (
<button onClick={this.fireEvent}>
You Click to toggle. {text}
</button>
);
}
});
module.exports = NavigationDiv;
<button onClick={this.handleClick}>? It should work this way.