score:5

Maybe this fiddle could point you in right way

var Hello = React.createClass({
    render: function() {
        return <div>Hello {this.props.name}
            <First1/>
            <First2/>
        </div>;
    }
});

var First1 = React.createClass({
    myClick: function(){
        alert('Show 1');
        changeFirst();
    },
    render: function() {
        return <a onClick={this.myClick}> Saludo</a>;
    }
});

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 <span> Saludo {this.state.myState}</span>;
    }
});

React.render(<Hello name="World" />, document.getElementById('container'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.1/react-with-addons.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.1/JSXTransformer.js"></script>
<script src="https://facebook.github.io/react/js/jsfiddle-integration.js"></script>

<div id="container">
    <!-- This element's contents will be replaced with your component. -->
</div>

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.


Related Query

More Query from same tag