Skip to content

2.0.0-beta.31: Hydration mismatch when using nested conditionals in <Show when> #2976

Description

@dangkyokhoang

Describe the bug

This pattern causes hydration mismatch:

function Badge(props: { required?: boolean; optional?: boolean }) {
  return (
    <Show
      when={props.required ? 'Required' : props.optional ? 'Optional' : null}
    >
      {(text) => <span>{text()}</span>}
    </Show>
  );
}

Your Example Website or App

https://stackblitz.com/edit/nitrojs-nitro-x1i4tv9d?file=src%2Fapp.tsx

Steps to Reproduce the Bug or Issue

  1. Go to the link above
  2. See console logs

Expected behavior

No issue

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

Related: #2959

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions