i have a problem with a react video component, i have 2 component, the first is a video component, he can play youtube video, the second is a list of video element, and when i click on a child of this list, i want to change the video of the first component ( the video component ), but i try since 2 hours to send new props to another component, and i can't do this.
This is my code for:
1st component ( video block )
var VideoMainItem = React.createClass({
getInitialState: function() {
return {
video: null
};
},
handleClick: function() {
var button = $(this.refs.button);
var thumbnail = $(this.refs.thumbnail);
button.hide();
thumbnail.hide();
this.setState({
video: <VideoHook source={this.props.source} />
});
},
render: function() {
return (
<div className="nativ-VideoBlockComponent-main">
<div className="nativ-VideoBlockComponent-main-video">
<span ref="button" onClick={this.handleClick} className="nativ-VideoBlockComponent-main-video-button"></span>
<div ref="thumbnail" className="nativ-VideoBlockComponent-main-video-thumbnail"></div>
{this.state.video}
</div>
<div className="nativ-VideoBlockComponent-main-content">
<span className="nativ-VideoBlockComponent-main-content-title">Lorem ipsum dolor sit amet</span>
<span className="nativ-VideoBlockComponent-main-content-description">At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias Excepturi sint occaecati cupiditate non provident.</span>
</div>
</div>
);
}
});
2nd component ( list of videos )
var VideoCarousselItem = React.createClass({
getInitialState: function() {
return {
video: this.props.video
};
},
addThumbnail: function(video) {
return {
'backgroundImage': 'url(' + asset('assets/images/videoblock/thumbnail_01.jpg') + ')'
};
},
handleClick: function() {
console.log('VideoCarousselItem::handleClick');
<VideoMainItem video={this.state.video} />
},
render: function() {
return (
<div className="nativ-VideoBlockComponent-caroussel-item">
<span className="nativ-VideoBlockComponent-caroussel-item-button"></span>
<div onClick={this.handleClick} className="nativ-VideoBlockComponent-caroussel-item-thumbnail" style={this.addThumbnail(this.state.video)}></div>
</div>
);
}
});
If any people have a solution or an alternative, thank you in advance
Regards
William