Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization: static react children #8

Open
bfanger opened this issue Jun 26, 2022 · 0 comments
Open

Optimization: static react children #8

bfanger opened this issue Jun 26, 2022 · 0 comments

Comments

@bfanger
Copy link
Owner

bfanger commented Jun 26, 2022

If the default slot of a <react:Component> only contains other <react:Component>s and no Svelte components or control-flow these components could be compiled into a children prop.

<react:Header><react:Logo href="/" /></react:Header>

could be compiled to:

<React$Header children={ createElement(Logo, { href: "/" }) } />

Note:
This could lead to surprises like:

<react:Tabs>
  <react:Tab>Tab 1</react:Tab>
  <react:Tab>Tab 2</react:Tab>
<react:Tabs>

working but it will stop working for:

<react:Tabs>
  <react:Tab>Tab 1</react:Tab>
  <react:Tab>Tab <strong>2</strong></react:Tab>
<react:Tabs>

because of the <strong> it wil opt-out of the optimisation and now Tabs no longer get the Tab components as direct children. Maybe the optimised version should also wrap the children into a "useless" fragment.

Related #43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant