Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created December 21, 2013 23:20
Show Gist options
  • Save swannodette/8076512 to your computer and use it in GitHub Desktop.
Save swannodette/8076512 to your computer and use it in GitHub Desktop.
<html>
<head>
</head>
<body>
<div id="test"></div>
<script src="http://fb.me/react-0.5.1.js"></script>
<script src="test.js"></script>
</body>
</html>
(function() {
"use strict";
var InputTestComponent = React.createClass({
render: function() {
if(this.refs && this.refs.textField) {
var tf = this.refs.textField,
node = tf.getDOMNode();
console.log("this.props.text:", this.props.text);
console.log("textField.state.value:", tf.state.value);
console.log("textFieldNode.value", node.value);
}
var self = this;
return React.DOM.input({
ref: "textField",
value: this.props.text,
onChange: function(e) {
var target = e.target,
value = e.target.value;
requestAnimationFrame(function(){
renderRoot(value);
});
}
});
}
});
function renderRoot(text) {
React.renderComponent(
InputTestComponent({text: text}),
document.getElementById("test")
);
}
renderRoot("foobar");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment