unirakun/hoc-little-router

Manage Page Not Found through hoc

bpetetot opened this issue · 5 comments

Display a "page not found" component when router can't match any title prop in routing configuration tree :

Example :

forRoute('HOME', { notFound: Page404 })(App)

I think we have only one not found page.
if we define a default TITLE route for error page and not found page on list of routes ?

export const { reducer, enhancer, middleware } = routerForBrowser({
  routes: {
    '/': { title: 'HOME',
      '/500': { title: '500' },
      '/404': { title: '404' },
    },
  },
  basename,
})

And

forRoute('HOME', { 404: 'CUSTOM_404', 500: 'CUSTOM_500' })(App)

to extends default usage ?

We speak about this solution with @bpetetot .
What does allow the { notFound: Page404 } is to have multiple "not found" pages depending where you are on the graph:

/
  - contacts/
     - Page404Contacts
  - cities/
     - Page404Cities

With your solution @guillaumecrespel, we only have one 404 page in the whole application since title are uniq.

This issue is more about the "Route Not Found" and not the "404 not found" (the HTTP error due to a network request not found)

When a user types a route that doesn't exist, I want to display an error page and eventually different page, when the route is not found at different levels of the graph (as @fabienjuif said in the previous post)

Yes you are write about the definition :)