javascript – onFocus and onBlur does not render in react
javascript – onFocus and onBlur does not render in react
Is this what you are looking for?
http://codepen.io/comakai/pen/WvzRKp?editors=001
var Foo = React.createClass({
getInitialState: function () {
return {
type: text
};
},
onFocus: function () {
this.setState({
type: date
});
},
onBlur: function () {
this.setState({
type: text
});
},
render: function () {
return(
<input
type={ this.state.type }
onFocus={ this.onFocus }
onBlur={ this.onBlur }
placeholder=Enter your date here.
/>
)
}
});
React.render(<Foo/>, document.body);
As Ive commented above, the render method triggers the first time and after that on every state change (and if shouldComponentRender returns true in case if its implemented):
https://facebook.github.io/react/docs/component-specs.html