SolidJSS
SolidJS10mo ago
19 replies
Maciek50322

Solid router, suspense and navigate

<Router root={<App>{props.children}</App>}>
  {routes}
</Router>

export default function App(props: { children: JSX.Element }) {
  const navigate = useNavigate();
  const location = useLocation();
  createRenderEffect(() => {
    if (location.pathname !== "/login") navigate("/login")
  });

  return <Suspense>{props.children}</Suspense>
}

I have 2 routes, let's say
/login
and /home, the login file is small, loads in 1s, home file is big loads for 10s (because of dependencies).
In the case above initially going to /home, it redirects as fast as it can to
/login
.
The
/login
file is loaded, but suspense still holds until the /home file is loaded, then it shows
/login
.
How can I make it show
/login
just as soon as it loaded, not waiting for /home ?
(not solid start)
(Tried it in production build)
Was this page helpful?