alibaba / alibaba/rax

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

Open
#2,329 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug
Dominant language
JavaScript
Stars
8k
Forks
611
PR merge metrics
No merged PRs in 30d

Description

⌨️

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/rax/src/vdom/shouldUpdateComponent.js at the mentioned method and compare its handling of undefined with the linked null-node fix. Reproduce the UndefinedDemo example by toggling the button; done means an undefined child is updated rather than rebuilt.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.