Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useIsRouting returning true from SSR and causing Suspense issues #418

Closed
sabercoy opened this issue May 12, 2024 · 2 comments
Closed

useIsRouting returning true from SSR and causing Suspense issues #418

sabercoy opened this issue May 12, 2024 · 2 comments

Comments

@sabercoy
Copy link

Describe the bug

In @solidjs/router 0.13.1, using useIsRouting() inside the root component would yield false
now it yields true and the markup for this result is sent to the client, then when the component mounts it switches to false

export default function App() {
  return (
    <Router root={props => {
        const isRouting = useIsRouting()

        return (
          <MetaProvider>
            <Show when={isRouting()}>
              <div>LOADING...</div>
            </Show>
            <a href="/">Index</a>
            <a href="/about">About</a>
            <Suspense>{props.children}</Suspense>
          </MetaProvider>
        )
      }}
    >
      <FileRoutes />
    </Router>
  );
}

when it switches everything inside Suspense is removed from the DOM for some reason

all of this may be expected from changes in 0.13.2 and 0.13.3, but I am placing it here in case this behavior is not intentional. This makes it more difficult to have global handling for displaying a loader during routing.

Your Example Website or App

https://github.com/sabercoy/solid-start-useIsRouting

Steps to Reproduce the Bug or Issue

clone the repo, install deps, run dev

Expected behavior

I expected the behavior to remain the same as 0.13.1

Screenshots or Videos

Screencast.from.2024-05-11.23-40-30.mp4

Platform

  • OS: Linux
  • Browser: Chrome

Additional context

No response

@sabercoy
Copy link
Author

After playing with Suspense more, it looks like the issue of removing DOM elements can be fixed by wrapping {props.children} like <div>{props.children}</div> so perhaps this is some Suspense hydration issue.

But still, need to confirm if useIsRouting() should now be true on app load

@ryansolid
Copy link
Member

I mean the error is but it still shouldn't happen. I believe it is fixed in 0.13.6 as I can't reproduce in the reproduction after upgraind. There were some missteps around 0.13.3 but I think we are back in a good spot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants