Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: props.activeRoute does not render #76

Closed
jasonkuhrt opened this issue Jul 9, 2014 · 4 comments
Closed

Bug: props.activeRoute does not render #76

jasonkuhrt opened this issue Jul 9, 2014 · 4 comments

Comments

@jasonkuhrt
Copy link

Strange issue:

I had a root Route handler like this:

var App = React.createClass({
  displayName: 'App',
  render: function(){
    return  E.p(null,
              Router.Link({ to:'dashboard' }, 'dashboard'),
              Router.Link({ to:'intro' }, 'intro'),
              this.props.activeRoute
            )
  }
})

This worked fine when loading the page at / and navigating from there. But if I loaded the page at e.g. /#/dashboard then dashboard is not rendered... (but oddly if I console.log(this.props.activeRoute) it does have value!. My workaround is to use App handler for basically just returning this.props.activeRoute or a temporary DOM node:

var App = React.createClass({
  displayName: 'App',
  render: function(){
    if (this.props.activeRoute) return this.props.activeRoute
    return  E.div()
  }
})
@jasonkuhrt jasonkuhrt changed the title props.activeRoute does not render Bug: props.activeRoute does not render Jul 9, 2014
@ryanflorence
Copy link
Member

What does your route config look like, and your dashboard handler?

@jasonkuhrt
Copy link
Author

@rpflorence Here is the code:

var App = React.createClass({
  displayName: 'App',
  render: function(){
    return  E.p(null,
              Router.Link({ to:'dashboard' }, 'dashboard'),
              Router.Link({ to:'intro' }, 'intro'),
              this.props.activeRoute
            )
  }
})

var viewDashboard = React.createClass({
  displayName: 'dashboard',
  render: function(){
    return E.p(null, 'a!')
  }
})

var viewIntro = React.createClass({
  displayName: 'intro',
  render: function(){
    return E.p(null, 'intro!')
  }
})

var routes =  Route({ handler: App },
                Route({ name: 'intro', handler: viewIntro }),
                Route({ name: 'dashboard', handler: viewDashboard })
              )

doc_ready(function(){
  React.renderComponent(routes, document.body)
})

The issue is that I was nesting views into a p element! Again some error feedback would have been helpful but ultimately there is no bug in RNR here, sorry : )

@ryanflorence
Copy link
Member

Perhaps react could tell you your HTML is invalid, but certainly not the router :) glad you tracked it down.

@jasonkuhrt
Copy link
Author

but certainly not the router :)

Yeah of course, @spicyj then

@lock lock bot locked as resolved and limited conversation to collaborators Jan 25, 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

No branches or pull requests

2 participants