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

[Bug?]: Hydration mismatch when using <Switch> <Match> tags #1672

Open
2 tasks done
YosefBayoude opened this issue Nov 5, 2024 · 1 comment
Open
2 tasks done

[Bug?]: Hydration mismatch when using <Switch> <Match> tags #1672

YosefBayoude opened this issue Nov 5, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@YosefBayoude
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Getting hydration mismatch errors

Expected behavior 🤔

The component should render

Steps to reproduce 🕹

Steps:

  1. Install Tanstack query
  2. Call fetch() with Tanstack query (regular async functions do not seem to cause this issue)
  3. Use a <Switch> <Match> </Match> </Switch>
  4. Reload the page and watch the error happen

Another way I did this, was to take the existing example from Tanstack query, and simply add a <Switch> <Match> </Match> </Switch>, can be found in the 'Mixed' page here : https://stackblitz.com/edit/tanstack-query-regvcz?file=src%2Fcomponents%2Fuser-info.tsx
This issue only seems to happen on the first fetch() call.

Context 🔦

As mentioned by #1174 (comment), I'm opening a new issue here, since the previous one was crowded.
Another point of note, I don't know if this is an issue related to Tanstack query, or with Solid Start, but since the error shows hydration issues, specifically with the use of <Switch> <Match> </Match> </Switch>, I thought I would put it here.
Let me know if this needs to go Tanstack instead.

Your environment 🌎

OS: MacOS Sonoma
solid-start: 1.0.10
@YosefBayoude YosefBayoude added the bug Something isn't working label Nov 5, 2024
@YosefBayoude YosefBayoude changed the title [Bug?]: Hydration mismatch [Bug?]: Hydration mismatch when using <Switch> <Match> Nov 9, 2024
@YosefBayoude YosefBayoude changed the title [Bug?]: Hydration mismatch when using <Switch> <Match> [Bug?]: Hydration mismatch when using <Switch> <Match> tags Nov 9, 2024
@ryoid
Copy link
Contributor

ryoid commented Nov 27, 2024

I believe this is the same issue as this.

The recommendation is to instead use Suspense and ErrorBoundary

<Suspense fallback={<p>Loading...</p>}>
  <ErrorBoundary fallback={<p>Error: {query.error?.message}</p>}>
    <div>id: {user.id}</div>
    <div>name: {user.name}</div>
    <div>queryTime: {user.queryTime}</div>
    <button
      onClick={() => {
        query.refetch();
      }}
    >
      refetch
    </button>
  </ErrorBoundary>
</Suspense>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants