I have 2 component, how do I pass user entered value through onChange to parent component? I'm able to pass the 'trigger' upon onChange, but how to pass the value along?
var InputComp = React.createClass({
render: function() {
return (
<div>
<input type="text" onChange={this.props.newVal} />
</div>
);
}
});
var App = React.createClass({
getInitialState(){
return {
inputVal: 0
}
},
inputChangedHandler(props) {
//set user changed value to inputVal
console.log(props)
},
render() {
return(
<div>
<InputComp newVal={this.inputChangedHandler}/>
<h4>{this.state.inputVal}</h4>
</div>
)
}
})
ReactDOM.render(
<App />,
document.getElementById('container')
);