-
-
Notifications
You must be signed in to change notification settings - Fork 634
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
Rendering fragments #501
Comments
Mounting fragments is cheap, it's the moving/removing fragments that introduces complications since they can be seen as essentially a paired set. I'm interested in knowing how React-Fiber rewrite does this if they do and to what extent. |
having a similar convo over at domvm/domvm#106 |
@thysultan support for fragment rendering in React Fiber is mentioned here: https://github.com/acdlite/react-fiber-architecture#child-and-sibling Also I've heard it described in one talk, but can't recall enough about it to find it again :) And if we are comparing different solutions, mithril (rewrite branch) also supports it. Mithril also flattens all children by default (pretty useful when templating in hyperscript), so you can pass nested arrays and it gets resolved properly. Dunno if that is also the behavior in Inferno/React. |
So this will likely going in for the future along with my refactor of normalization within Inferno. It won't be in for 1.0 due to the amount of edge cases it brings and things it breaks for now. |
#628 is now closed. Should this issue be reopened now that React 16 is out and has this feature? |
Yeah lets re-open, it will be there in next major release. |
This will come in v5 |
@Havunen I see you've been doing some work on this recently - does it look like it may be released soon? |
Next big release will be v4, which does not include fragments. They were dropped out due to some bugs. Also fragments are in jsx plugin which is currently in beta. I think its better to wait babel / facebook to stabilize the feature and then we can implement it. |
v5 is out, is this now supported? |
@SeanHayes V5 was in this case a major breaking change fix with esm modules. So this will most likely come with V6 |
Unfortunately Next.js is using the short syntax of Related issue at next.js: |
Here is the original feature discussion for fragments in |
This could also be solved by babel JSX plugin similar to: |
We need |
So what happened? is there any progress about this feature? I'd love to know :-) |
I`m in USA FL atm. This is currently first task in my todo list. I will continue it Aug 6th unless somebody wants to send PR :-) |
This is now finally out for testing! Please see |
Hmm i tried the last one v6.0.0-rc.1 still Fragment is not working for me |
@simonjoom do you use JSX? Did you remember to update babel-plugin-inferno to Are you getting any error message? |
i ve got the latest inferno took from github and builded manually. I created a repo merging gatsby with inferno, it's working nice) https://github.com/simonjoom/gatsby-starter-inferno-master |
hello, i just tried without success with the branch dev as well. the plugin is well installed with webpack and babel config So i tried with
I ve got "export 'Fragment' was not found in 'react' as well Thanks |
@simonjoom I believe you're meant to use |
Hmm, did you configure the babel plugin correctly @simonjoom? And check if your configuration in
I can't find the babel plugin in your gatsby starter. If you do not intent to use it, you must write the fragments using what @trueadm suggested (check out the tests for the plugin's fragments implementation - basically what the plugin transforms your jsx code into infernojs/babel-plugin-inferno@6071ba7#diff-ce4097fa41097a3b63603226458faf55R309) |
I think the issue was because new methods were not exported from inferno-compat. I will make new release |
@simonjoom can you test |
hello yes it's working great now:) thanks ok i know it's stupid to do Maybe ping KyleAMathews from gatsby about the status of inferno, i think it's interesting for gatsby now. |
about the starter repo i did, i did not updated properly it, so well yes babel-plugin was not well configured when you wrote these lines. |
@simonjoom if you are rendering component it needs to be written That use case should work unless there is bug somewhere. |
yes sorry i wrote badly here. but on my app it's well written like: and it's return nothing in rendering so yes it's a bug from inferno Nota if i add an other component or a node inside then MyComponent well render |
@simonjoom Interesting, can you create steps to reproduce it somewhere? Maybe github repository? I need to be away for a while, but when I'm back I would like to have a look at that issue. |
@simonjoom I Just published |
ok do that now :) |
hello ok the issue of single fragment is still here unfortunately with the last version you asked me to try. Nota: now it's returning [{object}, {object}] in the html not anymore null (i'm not sure it's can help...) Anyway looking at the source code i found that in develop mode i ve got some: was the same thing than preactjs/preact#1058 Because i use pragma I can confirm then that babel-plugin-inferno is well working for me.
In my webpackconfig i use alias:
|
i found a bug from a code like that:
in looking in the source code:
it's appear that the code didn't recognize the fragment and children is null for here If i change the fragment to normal div i ve got no issue at all |
ok again something to read: I found a very strange behavior with inferno; I thought was my code but in normal mode (without inferno) i ve not this issue to |
That was fixed by recent PR c7113bc babel config:
This will not work as you expect, because inferno JSX elements are compiled into different calls and not createElement, See https://github.com/infernojs/babel-plugin-inferno#pragma
I have not seen that kind of function callback API, so I guess that's the issue here. |
ok nice that you fixed input type in c7113bc (even if it's still not released in your last version) About pragma, i adjust it just to avoid some bad output in source code. even the simplest React component wrapped around fragment will still return anything in render. Regards |
I found a bad behaviour using Fragment with inferno,
But if i use fragment the behaviour is that all the components inside the fragments unmount (destroy) when i do a push history, so for now i recommand to turn all Fragment to div container |
@simonjoom I cannot reproduce the issue you are having. ( Single component inside fragment ) Can you check this file what test case is missing? This example
Will not work in InfernoJS because it needs new context API. I might know what you mean with Router issue. So all components there re-mount right? I will look into that tomorrow, its most likely about normalization. Thanks for the help! |
yes all remount However with normal react i have not this unmount. It's happened only after a change after state who modify the children components inside : I don't put all the class here because it's very complicate but it's like a component who (re)render a component depending location change. something like
Maybe it's can help you to figure out or replicate the issue
with Test:
I don't see any "unmountTest" on console when i run with react, with inferno i see "unmountTest" And yes tested without fragment with inferno i don't see any "unmountTest" About I use @reach/router who use context api too it's working. |
@simonjoom I have fixed the re-mount issue with Fragments, thanks for reporting it! Commit link here:
For that use case I'm still missing steps to reproduce, do you know how to reproduce it? |
Maybe you were using clone element and experienced this Bug #1393 ? |
Okay, the issue occurs only when using |
I'm closing this ticket as Inferno v6 is now released! 🎉 @simonjoom if you still experience issues with Fragments you can create new Github ticket and we can continue there. https://github.com/infernojs/inferno/releases/tag/v6.0.0 |
cool thanks.
|
Or in other words, support for components to render multiple children:
It was said on slack it's a wanted feature with intention to be implement in future, so I'm creating this issue to have a place to track the progress.
Someone mentioned that it was already once in Inferno, but at the cost of performance, so it was dropped until a faster implementation is discovered. Was the performance hit really that bad? Because I'd gladly take it if it means the ability to render fragments. Inferno is one of the fastest frameworks out there, so it definitely doesn't lack the perf budget.
I consider this to be an essential feature to not have DOM polluted with useless wrapper elements which just get in the way of developing, maintaining, and styling components. And React already supports this in their Fiber rewrite, which is mostly done.
The text was updated successfully, but these errors were encountered: