frontarm / navi

🧭 Declarative, asynchronous routing for React.
https://frontarm.com/navi/
MIT License
2.07k stars 71 forks source link

Lazy import not working with CRA 3.4 #173

Closed gut4 closed 4 years ago

gut4 commented 4 years ago

Looks like import is broken with CRA. Js chunk is generated but not rendered. I try dev and production. – dev show NotFoundError: URL not found: /test – production render nothing

test.js

export default mount({
  '/:id': route({
    view: <div>test page</div>
  })
})

app.js

const routes =
mount({
    '/test': lazy(() => import('./test')),
  })
function App () {
  return (
<Router routes={routes}>
      <Suspense fallback={null}>
        <View />
      </Suspense>
    </Router>
)}
jamesknelson commented 4 years ago

In this case, I think the reason that /test isn't being found, is that you've got no wildcard pattern on the mount() in test.js. Something like /test/hello will work, but /test by itself is still a 404.