Skip to content

Commit

Permalink
[changed] activeRoute is a function that returns null when no child r…
Browse files Browse the repository at this point in the history
…outes are active.
  • Loading branch information
luigy committed Jul 18, 2014
1 parent 2d0fb47 commit 991dede
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions examples/master-detail/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ var App = React.createClass({
var contacts = this.state.contacts.map(function(contact) {
return <li key={contact.id}><Link to="contact" id={contact.id}>{contact.first}</Link></li>
});
var content = (this.props.activeRoute) ? this.props.activeRoute() : this.indexTemplate();
return (
<div className="App">
<div className="ContactList">
Expand All @@ -121,7 +120,7 @@ var App = React.createClass({
</ul>
</div>
<div className="Content">
{content}
{this.props.activeRoute() || this.indexTemplate()}
</div>
</div>
);
Expand Down
5 changes: 3 additions & 2 deletions modules/components/Route.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var React = require('react');
var warning = require('react/lib/warning');
var invariant = require('react/lib/invariant');
var emptyFunction = require('react/lib/emptyFunction');
var ExecutionEnvironment = require('react/lib/ExecutionEnvironment');
var mergeProperties = require('../helpers/mergeProperties');
var goBack = require('../helpers/goBack');
Expand Down Expand Up @@ -426,7 +427,7 @@ function computeHandlerProps(matches, query) {
key: null,
params: null,
query: null,
activeRoute: null
activeRoute: emptyFunction.thatReturnsNull
};

var childHandler;
Expand All @@ -443,7 +444,7 @@ function computeHandlerProps(matches, query) {
if (childHandler) {
props.activeRoute = childHandler;
} else {
props.activeRoute = null;
props.activeRoute = emptyFunction.thatReturnsNull;
}

childHandler = function (props, addedProps, children) {
Expand Down

0 comments on commit 991dede

Please sign in to comment.