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

Add support for fragments #4

Closed
klintmane opened this issue Jul 16, 2021 · 1 comment
Closed

Add support for fragments #4

klintmane opened this issue Jul 16, 2021 · 1 comment

Comments

@klintmane
Copy link
Owner

klintmane commented Jul 16, 2021

We should investigate wether adding support for fragments is worth it or not.

According to pomber/didact#22, the current commitDeletion:

... The trick is: if fiber.dom is null it means it's the fiber of a function component, and function components never have more than one child (Didact doesn't have Fragments like React).

Adding support for multiple children would:

It's more complex because you need to search the different dom nodes that may be at different levels on the subtrees.
See here: https://gist.github.com/pomber/64fb7e63119bef201dd8166b0fce73c4#file-didact-fiber-js-L30 (from https://engineering.hexacta.com/didact-fiber-incremental-reconciliation-b2fe028dcaec)

Edit: Found a project implementing Fragments on Didact at https://github.com/davidbarone/didact#fragments

@klintmane
Copy link
Owner Author

Creating a Fragment component of value null seems to do the trick.

export const Fragment = null;

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