Let's say I have nested components like this:
<root />
<comp1 />
<comp2 />
<target id={this.props.id}>
<div>click me</div>
I want to make clicking on target run a function on root:
//on root component
this.action = function(id){}
Do I need to do manually set a property on every component in the chain, like in the React tutorial example? Jsfiddle
<root />
<comp1 clickHandler={this.action}/>
<comp2 clickHandler={this.clickHandler}/>
<target id={this.props.id} clickHandler={this.clickHandler} />
<div onClick={this.props.clickHandler.bind(this, this.props.id)}>click me</div>
Or is there some way to bubble the events up like in normal DOM?