Skip to content

Unexpected null ref #4049

@jakearchibald

Description

@jakearchibald
  • Check if updating to the latest Preact version resolves the issue

Describe the bug

A ref is unexpectedly null when using a particular JSX structure.

To Reproduce

Demo.

View the console. I see:

{phase: 1, oneRef: null, twoRef: div, threeRef: div}
{phase: 2, oneRef: div, twoRef: null, threeRef: div}

Expected behaviour

{phase: 1, oneRef: null, twoRef: div, threeRef: div}
{phase: 2, oneRef: div, twoRef: div, threeRef: div}

It's expected that oneRef is null in phase 1 (the element isn't rendered), but twoRef shouldn't be null in phase 2, as the element is rendered.

The bug seems to depend on a few things:

If <div class="wrapper"> is switched to a fragment, the bug still happens. However, if <div class="wrapper"> is removed, the bug does not happen.

If <div class="outer"> is switched to a fragment, the bug does not happen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions