In the App component of this line
<videos handle={this.handleDrag(vidurl)} />
incorrectly, you need to pass a callback function instead of a function call.
In VideoForm, this line
return <img src="http://upload.wikimedia.org/wikipedia/en/a/a6/Size_Small.PNG" onDrag={this.props.handle.bind(this.state.vidurl)}></img> //trying to send state value from here
wrong, this.props.handle is the parent callback, you just need to call this.props.handle (this.state.videoUrl)
Correct implementation:
var APP = React.createClass({ getInitialState:function() { return {url:'http://www.youtube.com/embed/XGSy3_Czz8k'} }, // Parent callback, pass this function to the child component handleDrag:function(videoUrl) { alert(videoUrl); }, render: function() { return ( <div> <Videos handle={this.handleDrag} /> </div> ); }) var Videos = React.createClass({ getInitialState:function() { return {vidurl:'http://www.youtube.com/embed/XGSy3_Czz8k'} }, handleChanged: function(event) { if(this.props.handle) { this.props.handle(this.state.videoUrl); } }, render:function() { return <img src="http://upload.wikimedia.org/wikipedia/en/a/a6/Size_Small.PNG" onDrag={this.handleChanged}></img> //trying to send state value from here } });
Icyright
source share