Last active
November 1, 2015 18:26
-
-
Save cacheflow/2563ea751a8f749389f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var React = require('react'); | |
var ReactDOM = require('react-dom'); | |
var Append = React.createClass({ | |
getInitialState: function() { | |
return { | |
logs: [] | |
}; | |
}, | |
handleClick:function(clickEvent) { | |
clickEvent.preventDefault(); | |
var logMsg = "default " + clickEvent.type + " prevented"; | |
var oldLogState = this.state.logs; | |
var newLogState = oldLogState.concat(logMsg); | |
this.setState({logs: newLogState}); | |
console.log(this.state.logs); | |
}, | |
render:function() { | |
var logs = this.state.logs.map(function(logs, index) { | |
return ( | |
<div key={index}> {logs} </div> | |
); | |
}); | |
return ( | |
<div> | |
<a href="#" onClick={this.handleClick}>Click me</a> | |
{logs} | |
</div> | |
) | |
} | |
}); | |
ReactDOM.render(<Append/>, document.getElementById("main")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment