Replies: 2 comments 3 replies
-
Unironically, it happens to be that way. There's a lot of reasons why this isn't ideal (or achievable), but to back up this claim, I guess it doesn't matter if it should be inlined or not, there's not much performance gain anyways. |
Beta Was this translation helpful? Give feedback.
-
Please don't be quick to dismiss ideas. Here, I discovered an actual use case, rather than the one I offered on the initial post: We rendered a list using |
Beta Was this translation helpful? Give feedback.
-
Hi, I was wondering if you could implement a pragma for inlining a component, that amortizes function calls during compilation. Its syntax could be an expression like
{/* @inline */ <Icon /> }
:Compiled output should be equal to its handwritten equivalent:
The use case is sometimes we need to insert an element in multiple different positions inside the parent component. Rather than typing the element multiple times, it is more convenient to abstract it into a component and use that component. But it brings an extra cost which could be eliminated easily during compilation.
I don't know how JSX is parsed and transpiled but a simple replacement should not bring that much complexity.
Components without props will work out of the box but if component has props, responsibility of making sure that props resolve to a value should befall on the developer.
By the way, if if parent has the same props as the replaced child, a simple replacement still works:
Beta Was this translation helpful? Give feedback.
All reactions