I'd like to unmount a single react component, which belongs to a parent component containing three components total. The parent component has this render function:
render: function () {
return (
<div className={classes}>
<Navbar ref="navbar"/>
<Home ref="home"/>
<Footer ref="footer"/>
</div>
),
handleNavbarClick: function () {
// remove Home
}
if a user then clicks on a link in the navbar and I want to unmount the Home component, how would I do that? it seems like my only option is to do something like this (taken from react.js: removing a component), but this seems pretty gross:
render: function () {
var home = this.state.remove_home ? null : <Home ref="home />
return (
<div className={classes}>
<Navbar ref="navbar"/>
{home}
<Footer ref="footer"/>
</div>
),
handleNavbarClick: function () {
this.setState({remove_home: true});
}
Is that the appropriate react way to do things?