I am learning Reactjs. I have implemented one sample react app with rails. I have search a lots to find the solution but I didn\'t find any. I wanted to call another component
Maybe this fiddle could point you in right way
var Hello = React.createClass({
render: function() {
return Hello {this.props.name}
;
}
});
var First1 = React.createClass({
myClick: function(){
alert('Show 1');
changeFirst();
},
render: function() {
return Saludo;
}
});
var First2 = React.createClass({
getInitialState: function(){
return {myState: ''};
},
componentDidMount: function() {
var me = this;
window.changeFirst = function() {
me.setState({'myState': 'Hey!!!'})
}
},
componentWillUnmount: function() {
window.changeFirst = null;
},
render: function() {
return Saludo {this.state.myState};
}
});
React.render( , document.getElementById('container'));
Basically I use those links:
communicate between components
dom event listeners
It hopes this helps.
Also, you could use the container component and use it like a bridge between both components.