Created
December 21, 2013 23:20
-
-
Save swannodette/8076512 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
<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> |
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
(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