Skip to content

Conversation

tgriesser
Copy link
Contributor

I just tried to do something like this:

<Route name="app" path="/" handler={Application}>
      <Route name="job" path="job/:job_id/?" handler={JobLayout}>
          <Route name="report" handler={Report} />
          {__DEBUG__ && <Route name="debug" handler={Debug} />}
          <DefaultRoute handler={JobForm} />
     </Route>
</Route>

Where the __DEBUG__ var is injected via webpack at compile time. This works fine during development, but in production, the line becomes equivalent to {undefined}. This pattern for conditionally rendering nodes is fairly common in React. I thought it might make sense to allow this here by skipping over falsy values in the createRoutesFromChildren function.

Routes which are null/undefined should be skipped
in the React.Children traversal when creating routes.
This makes the Router's behavior closer match React
in handling empty elements.
@mjackson
Copy link
Member

Makes sense. Thanks for the PR @tgriesser !

mjackson added a commit that referenced this pull request Jan 20, 2015
@mjackson mjackson merged commit a8c158b into remix-run:master Jan 20, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants