[BUG] render returns undefined to undefined empty nodes are also rebuilt
Open
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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