diff --git a/js/app.js b/js/app.js index 6232b8461..f13e00c4f 100644 --- a/js/app.js +++ b/js/app.js @@ -39,7 +39,7 @@ var App = React.createClass({ return { viewingPage: viewingPage, drawerOpen: drawerOpenRaw !== null ? JSON.parse(drawerOpenRaw) : true, - pageArgs: val, + pageArgs: typeof val !== 'undefined' ? val : null, errorInfo: null, modal: null, startNotice: null, @@ -193,7 +193,7 @@ var App = React.createClass({ return ; case 'discover': default: - return ; + return ; } }, render: function() { diff --git a/js/page/discover.js b/js/page/discover.js index f551eed68..acd126925 100644 --- a/js/page/discover.js +++ b/js/page/discover.js @@ -268,20 +268,27 @@ var DiscoverPage = React.createClass({ componentDidUpdate: function() { if (this.props.query != this.state.query) { - this.handleSearchChanged(); + this.handleSearchChanged(this.props.query); } }, - handleSearchChanged: function() { - this.setState({ - searching: true, - query: this.props.query, - }); - - lighthouse.search(this.props.query, this.searchCallback); + componentWillReceiveProps: function(nextProps, nextState) { + if (nextProps.query != nextState.query) + { + this.handleSearchChanged(nextProps.query); + } }, - componentDidMount: function() { + handleSearchChanged: function(query) { + this.setState({ + searching: true, + query: query, + }); + + lighthouse.search(query, this.searchCallback); + }, + + componentWillMount: function() { document.title = "Discover"; if (this.props.query) { // Rendering with a query already typed @@ -293,7 +300,7 @@ var DiscoverPage = React.createClass({ return { results: [], query: this.props.query, - searching: this.props.query && this.props.query.length > 0 + searching: ('query' in this.props) && (this.props.query.length > 0) }; },