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

Conditional elements rendering out of order with only two siblings #172

Closed
nicknisi opened this issue Nov 15, 2018 · 0 comments
Closed

Conditional elements rendering out of order with only two siblings #172

nicknisi opened this issue Nov 15, 2018 · 0 comments

Comments

@nicknisi
Copy link
Member

Bug

If a sibling element is conditionally rendered, it is rendered out of order, unless there is a third node.

Package Version: 4.0.0

Code
A reproducible CodeSandbox: https://codesandbox.io/s/8n76x533y9 and
it's working in https://codesandbox.io/s/205y711wly because it has an extra sibling

class App extends WidgetBase {
  protected bigPredicate(contentRect: ContentRect) {
    return contentRect.width > 768;
  }
  protected render() {
    const { isBig } = this.meta(Resize).get("root", {
      isBig: this.bigPredicate
    });
    return (
      <div key="root">
        {isBig && <h1>First</h1>}
        <h2>Second</h2>
        {/* Adding a third node fixes it <h3>Third</h3> */}
      </div>
    );
  }
}

Expected behavior:

I would expect <h1>First</h1> to be rendered before <h2>Second</h2>.

Actual behavior:

<h2>Second</h2> is rendered before <h1>First</h1>.

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

1 participant