N
N
Nick V2015-11-10 14:15:33
Node.js
Nick V, 2015-11-10 14:15:33

Meteor-React-FlowRouter not dumping data from db on page reload?

Good day, there is such a route

renderMainLayoutWith = (component, pageTitle) ->
  DocHead.setTitle if pageTitle? then pageTitle else '404 - Page not found :('
  ReactLayout.render MainLayout,
    header: `<Header />`
    content: component
    footer: `<Footer />`

FlowRouter.route '/',
  name: 'Home'

  action: ->
    renderMainLayoutWith `<Home />`, @name

FlowRouter.route '/:url',
  name: 'MultiRouter'
  triggersEnter: [ ->
    url = FlowRouter.current().path
    try
      @renderName = Routing.findOne({link: url}).name
    catch TypeError
      @renderName = '404 - Page not found :('
  ]
  action: ->
    switch renderName
      when "Home" then renderMainLayoutWith `<Home />`, renderName
      when "About Me" then renderMainLayoutWith `<AboutMe />`, renderName
      when "Notebook" then renderMainLayoutWith `<Notebook />`, renderName
      when "Portfolio" then renderMainLayoutWith `<Portfolio />`, renderName
      when "Contacts" then renderMainLayoutWith `<Contacts />`, renderName
      else
        renderMainLayoutWith `<PageNotFound />`, renderName

FlowRouter.notFound =
  action: ->
    renderMainLayoutWith `<PageNotFound />`

If you navigate the navigation with the mouse, then Routing.findOne({link: url}).name works correctly, but if you refresh the page or enter an existing path manually, then the Uncaught TypeError: Cannot read property 'name' of undefined error appears. Why is that? and how to fix or bypass it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
E, 2015-11-13
@aylo

I would use ReactRouter if I were you.
Most likely, it does not have time to receive the data here
Try to check the Meteor.loggingIn() log through the console, according to my experience, when updating the page, Meteor.loggingIn() returns true and here you can already hang the loader as an option.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question