Search code examples
meteorreactjsflow-router

Flowrouter.path not working


I am using flow router with react and meteor. Im trying to link an element using href={FlowRouter.path('ReadProjectMeta', {_id})} and its not working the console gives me this error

router.js:347 There is no route for the path: /ReadProjectMeta

yet ive defined the route this way

FlowRouter.route("/ReadProjectMeta/:_id", {
  action(params) {
    mount(ReadProjectMetaLayoutContainer, {
      components: (<ReadProjectMeta  _id={params._id}/>)
    }
  )
 }
});

this is how the component looks like

const ProjectList = ({project}) => ({ 
  project.map(({_id, projectheader,projectsummary,projectdescription}) => (
    <li key={_id}>
      <a href={FlowRouter.path('ReadProjectMeta', {_id})}>{projectheader}</a>
    </li>
  ))
})

what could be the problem . Please help


Solution

  • Try this way:

      FlowRouter.route("/ReadProjectMeta/:_id", {
        name: 'project.meta'
        action(params) {
          mount(ReadProjectMetaLayoutContainer, {
            components: (<ReadProjectMeta  _id={params._id}/>)
          })
        }
      });
    
      FlowRouter.path('project.meta', {_id:response});