Flow router redirect to not found

I set up a not found route in flow router and it works:

FlowRouter.notFound = {
    action: function() {
        ReactLayout.render(MainLayout, {content: <NotFound />});
    }
};

However, I have a route that takes a project ID param. To catch bad ID’s I have the following code:

render() {
    let content = null;
    if( this.data.projectLoading ){
        content = <Loading />;
    } else {
        if(this.data.project){
            content = <ProjectContent project={this.data.project}/>;
        } else {
            //Project Not found
            FlowRouter.go(FlowRouter.path('notFound'));
        }
    }
    return <div>{content}</div>;
},

It works but not correctly. Instead of routing to the not found page, it trys to find a notFound route and then fails to the not found page. Is there a better way to redirect to my not found page?

4 Likes

I have the same questions.
Did you find a way?

I just created a not found page error component:

} else {
      // Project Not found
      content = <PageError errorMessage="Project page not found." />;
}

My project was created 2 years ago. I haven’t used Meteor since, but you can view the code on my GitHub site.

1 Like