weixin_39789979
weixin_39789979
2020-11-26 18:19

404 Routes

Im wondering if there is a simplified method for checking all routes and 404 routes, I have found the following to work, but it would be ideal to have 404 capability available via a fragment:

All routes (Not sure why this works actually):


<fragment forroute="">
  <p>Matches all routes</p>
</fragment>

No route matches:


const App = (
  context: {
    router: RouterContext
  }
) => {
  const { matchRoute } = context.router.store;
  const matchResult = matchRoute(location.pathname);
  if(!matchResult) {
    return( <div> 404 error </div>)
  } else {
   return( <div> Application </div>)
 }
}

该提问来源于开源项目:FormidableLabs/redux-little-router

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

5条回答

为你推荐

换一换