-
Notifications
You must be signed in to change notification settings - Fork 26
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
Fragments? #76
Comments
Unlike React, Surplus supports returning arrays just fine. So instead of: return <>
<div/>
<div/>
<div>
</>; ... you can do ... return [
<div/>,
<div/>,
<div>
]; I've got on my list to support the fragment syntax as syntactic sugar for the array version but haven't hit that yet. Hope that helps! |
Thank you, that was fast! I was trying with arrays, but I can't make it work. I keep getting <html>
<head>
</head>
<body>
<div id="app"></div>
<script src="main.js"></script>
</body>
</html> and this is import S from 's-js';
import * as Surplus from 'surplus';
import data from 'surplus-mixin-data';
var Name = (name) => [<div>{name}</div>, <div>{name}</div>]
var Page = ( { children }) => <div>{children}</div>
document.getElementById("app").appendChild( Page( { children : Name("Jelly") } ) ) |
Strange, that code looks fine. I tried throwing it into a CodePen, and it appears to run there: https://codepen.io/adamhaile/pen/RYdZXO?editors=1000 . Maybe something with your build environment? Is it possible to zip up your project (maybe minus node_modules) and attach? |
Don't mean to pile on, but I added that code sample to an open project (webpack, typescript) and it worked for me, too. Outputs a div with two inner divs that have the text "Jelly". Might be helpful to paste the content of main.js along with the project. |
It works, strange... I had to remove the compiled file |
By the way, if you want an actual element instead of using arrays, you can simply make a stub element: const Fragment = ({children}) => children;
const MyComponent = () => (
<Fragment>
<div>Hello</div>
<div>World</div>
</Fragment>
); |
Deleted my comment about this being closeable - Surplus should definitely support the I might take a whack at this. |
Hello, really nice library. I was just playing around and realized that fragments are not supported.
Is there any way to implement views without a parent node?
The text was updated successfully, but these errors were encountered: