I am trying to find the Facebook Reactjs library and found it great. I went through an exam / textbook and got his job.
Now I am: http://facebook.imtqy.com/react/docs/interactivity-and-dynamic-uis.html
And I tried the code:
var LikeButton = React.createClass({ getInitialState: function() { return {liked: false}; }, handleClick: function(event) { this.setState({liked: !this.state.liked}); }, render: function() { var text = this.state.liked ? 'like' : 'unlike'; return ( <p onClick={this.handleClick}> You {text} this. Click to toggle. </p> ); } }); React.renderComponent( <LikeButton />, document.getElementById('example') );
After executing the code above, I get nothing. In my Chrome Chrome console, the error I received was Uncaught SyntaxError: Unexpected token < , in a line starting with <p onClick={this.handleClick}>
I was wondering if there is anyone who can enlighten me about what is wrong with the code?
Best wishes.
javascript facebook reactjs
DjangoRocks
source share