alibaba / rax

🐰 Rax is a progressive framework for building universal application. https://rax.js.org
Other
8k stars 627 forks source link

[BUG] render returns undefined to undefined empty nodes are also rebuilt #2329

Open carlisliu opened 2 years ago

carlisliu commented 2 years ago

⌨️

Rax Core

Minimal code and steps to reproduce the bug

import { Component } from 'rax';

class UndefinedDemo extends Component {
  constructor(props) {
    super(props);

    this.state = {
      alwaysUndefined: false,
    };
  }

  render() {
    return (
      <div>
        {this.state.alwaysUndefined ? undefined : undefined}

        <button
          onClick={() => {
            this.setState({
              alwaysUndefined: !this.state.alwaysUndefined
            });
          }}
        >
          Switch
        </button>
      </div>
    )
  }
}

reference: fix: render returns null to null empty nodes are also rebuilt(#1830) #1842

shouldUpdateComponent method should also checkundefined type.

Current and expected behavior

current: undefined node is rebuilt

expected: undefined node is updated

Environment

Rax Version: 1.2.2

build.json

No response

Possible solution

No response

Additional context

No response

nick950222 commented 2 years ago

image

SoloJiang commented 2 years ago

The problem has been solved https://github.com/alibaba/rax/pull/2275