Earlier quoted context omitted.
> Also, in order to transform JSX into individual rerunnable functions, we'd need a whole different transpiler. I don't think you would. ` ` gets converted by current transpilers into `jsx(Component, { prop: "example" })`. The `Component` itself is passed as is. In the case of Components that are just functions, that passes the function as-is, as a function you can just call as needed. JSX was built for "rerunnable f…
The problem is that JSX transpilers will put child nodes in an array, instead of in an anonymous function, meaning there is no easy way (without transpiler magic) to rerender just a part of the component. This JSX: Welcome {data.enabled ? : "disabled"} Which becomes this with Babel: _jsx("section", {children: [ _jsx("h1", {children: "Welcome"}), data.enabled ? _jsx("input", {}) : "disabled" ]}) But we'd need somethin…
render() {
if (this.dontNeedToRender) {
return null
}
}
Now, because hooks can't be skipped, react developers jump through many hoops to use an if statement during rendering.