I have a situation where I have 3 components; <View>
<Content>
and <Footer>
.
<View>
is parent of <Content>
and <Footer>
. Now there is a button in <Footer>
and when it is clicked, I want to render an Overlay
in the <Content>
component, so i have to have access to this
of the <Content>
component inside my <Footer>
component. I am not getting on how to accomplish that.
View.js
class View extends Component {
render() {
return (
<div>
<Content messages={this.props.messages}/>
<Footer />
</div>
)
}
}
Content.js
class Content extends Component {
render() {
return (
<div>
{this.props.messages}
</div>
)
}
}
Footer.js
class Footer extends Component {
constructor(props,context){
super(props,context);
this.state = {
showEmojiPicker: false,
}
}
handleToggleEmojiPicker() {
this.setState({
showEmojiPicker: !this.state.showEmojiPicker,
});
}
render() {
return (
<div>
<div>
<div>
<bootstrap.Button ref="targetEmojiPicker" bsSize="xsmall" onClick={this.handleToggleEmojiPicker.bind(this)}>
<bootstrap.Glyphicon glyph="heart" />
</bootstrap.Button>
<bootstrap.Overlay
show={this.state.showEmojiPicker}
onHide={this.handleClose.bind(this)}
container={content.this} //Need this of Content component
target={() => ReactDOM.findDOMNode(this.refs.targetEmojiPicker)}
>
<EmojiModalCategories actions={this.props.actions}/>
</bootstrap.Overlay>
</div>
</div>
</div>
)
}
}