Comments (8)
I've submitted to the JS Framework Benchmark the numbers look promising.
from solid.
@threeid The primary effect of the change in this RFC is control flow is no longer pre-compiled. They are just normal components. In so they cannot support special syntax that knows their behavior. So a syntax like this is unlikely without the possibility of indicating that the property is an argument and a way of indicating argument order. I suspect the resulting syntax might be more verbose and less obvious.
from solid.
In general I'm not a fan of the "Everything is a component" philosophy and when components become more than just pieces of UI.
Disregarding personal preference I think changing from $
to explicitly named tags like For
and Switch
has a benefit of making initial reasoning of what the pieces of code do a bit quicker.
But it's such a small syntactic change that the benefit mostly comes from the clear namings suggested than anything else.
So my two cents are that if it improves Solid then go for it. 👍
from solid.
The biggest benefit is perhaps this opens up people writing their own components that control downstream templating or not use Components at all. This opens up just using functions again and benefitting from optimized reconciliation. I still believe that for fine grained due to all the wrapping of accessors and deferred evaluation into computed contexts that Components or special directive-like helpers abstracts those details for beginners better since they provide a syntax that avoids that. So Components because of JSX.
Popular fine grained libraries don't let you wrap your own which set a precedence I was following in the name of optimization which didn't completely pan out. I will be performance tuning this approach to ensure we do not take a hit. But these helpers have a lot of functionality baked in for that reason that complicates and bloats unnecessarily for common cases. Components give a homogeneous way to offer different or extended functionality that has minimal impact on the consumer. Whether you use this For
component or someone else's ForBetter
component it's a simple swap.
from solid.
I think this looks great! One of my nit-picks about Solid was this kind of weird <$>
control flow that has limited TS support and discoverability.
I personally like the React way using .map
, ternaries and &&
since they are simply part of the language but this proposal actually makes me think these control flow components are the way to go. Routers tend to come with a <Switch>
component, <Portal>
and <Suspense>
have to be components anyways so making <For>
and <Map>
seems logical. Plus you get niceties like a fallback option. Additionally, if this reduces Solid's complexity and file size, that sounds like a win.
from solid.
It would be great to just use map and ternaries but there are complexities with reactive contexts that make this not the most optimal approach. Mostly since we are making real DOM nodes you can't just careless map the whole list. You need to use a memoized map. Ternaries are fine they just put all children in a tracking context. Also if the ternary is based on a condition, ie. state.count > 5
, everytime count updates it will re-evaluate the children. You can solve this by hoisting the children out of the condition, but control flow handles this all for you.
In any case, I'm happy to announce this has now been implemented and released with v0.9.0.
from solid.
I would love to write:
<for each={ state.list } item={ item }>
{ item }
</for>
<for each={ state.list } item={ { index, value } }>
{ index } : { value }
</for>
from solid.
Ok closing this. It's been a month now. So I think the discussion is done on this.
from solid.
Related Issues (20)
- Exports from ./dist do not include corresponding type declarations
- strange hydration mismatch HOT 3
- Typescript - Components created via JSX "forget"/erase their type HOT 3
- Custom elements using `is` not recognized as custom elements HOT 3
- onCleanup is called on the server and it breaks the astro app HOT 1
- [Bug?]: SuspenseList hydration error HOT 2
- computations created outside a `createRoot` or `render` will never be disposed HOT 3
- [Astro] `createResource` results get mixed up when rendering server only components with Suspense HOT 4
- Hydration Mismatch error HOT 6
- [Bug] Repeated call syntax in JSX breaks reactivity HOT 1
- [Astro] resource and signal rendering is mixed up on the client HOT 2
- Refs don't work correctly when using dynamic
- Refs don't work when optional on a component HOT 4
- Cannot use istanbul ignore comments for generated code HOT 2
- setting element reference in `setStore` modifies the values in the array HOT 13
- `this` inside jsx-template inside a constructor of a derived class causes transformation-bug HOT 2
- The update of props is not granular enough. HOT 4
- No value attribute on CSR, but present in SSR
- Cannot properly bind numbers to Select HOT 1
- Double mounting for children element. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from solid.