var React = require('react');
var {Col} = require('react-bootstrap/lib');
var Segment = require('../util/segment-data');
module.exports = React.createClass({
displayName: 'MyFilter',
propTypes: {
children: React.PropTypes.node,
component: React.PropTypes.string
},
render(){
return (
this.props.children
);
},
captureEventHandler(){
var data = {
label: e.target.innerText ? e.target.innerText : e.target.textContent
};
Segment.track(this.props.component, data);
}
});
Then
<SegmentFilter component={Events.sailing_schedules}>
<div onClick={this.handleSort.bind(null, 'departure_date')}>Departure Date <span className='caret'></span></div>
</SegmentFilter>
My question is that how do I capture click, enter or any event happening in children in the component SegmentFilter? Is it possible to not specify any DOM element inside render ? So basically I am asking how can I do it without doing the following.
return (
<div onClick={this.handleClick}>
{this.props.children}
</div>
);
handleClick(e){
var data = {
label: e.target.innerText ? e.target.innerText : e.target.textContent
};
Segment.track(this.props.component, data);
}
The reason I am avoiding this is because I don't want to specify any html of my wrapper component. Or at worst even if I use the div
how can I capture any event of child element inside parent component.
So I am looking to write a global event handler in Segment wrapper which will be called no matter which event fires and not only click in child elements. Let's say it should bubble upto that function handleClick
UPDATE - I referred this but couldn't find my case.