1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-25 18:56:28 +02:00

Hotfix for header accessing undefined ref

Sometimes `onRouteChange()` is triggered before the component’s refs
are available, so we have to check for them before setting their state.
This commit is contained in:
Brett Sun 2015-12-10 19:19:01 +01:00
parent b467a840a4
commit 6e9b1ac181

View File

@ -140,7 +140,9 @@ let Header = React.createClass({
// the collapsibleNav by itself on click. setState() isn't available on a ref so
// doing this explicitly is the only way for now.
onRouteChange() {
this.refs.navbar.state.navExpanded = false;
if (this.refs.navbar) {
this.refs.navbar.state.navExpanded = false;
}
},
render() {