Comments (5)
I would say that spreading is not what you want, you want the same behavior as you would get with arrays (if you ignore the key warning) with it being its own hierarchy and implicit indices computed accordingly. A previously discussed syntax is <>
, which is also consistent with E4X IIRC (for whatever it's worth).
Also, I imagine if we want to support spreading there's already a solution that wouldn't necessarily introduce new syntax <Parent>{...foobar}</Parent>
. Again, not sure why you would want it though as opposed to just fragments.
from jsx.
Don't I have to key the fragments?
Actually come to think of it, <Parent>{...foobar}</Parent>
would be nice too. That's what I was naively trying to do in the first place, only to stumble upon an error saying JSXSpreadAttribute
being not in the right place. I just failed to find any proposals about this syntax or <>
.
Is there any conceptual difference in React between
createElement(tag, styles, a, b, c, d)
createElement(tag, styles, a, [b, c], d)
createElement(tag, styles, a, createFragment({b, c}), d)
?
from jsx.
Don't I have to key the fragments?
@quassnoi Using React.createFragment
naively requires it yes, it's essentially an associative list (i.e. Map
), so everything has to be keyed by necessity. But you could easily feed an array to React.createFragment
(use index as key) or have JSX pre-compute the indices and assign keys accordingly.
I just failed to find any proposals about this syntax or <>.
Yeah, I'm not 100% sure TBH. It may just have been "informal/internal" discussions in other places.
Is there any conceptual difference in React between createElement(tag, styles, a, b, c, d) and createElement(tag, styles, a, [b, c], d)?
Yes, a very important one. Removing c
in the non-array case would cause React to destroy the instance for d
and try to reuse the instance for c
but now with the props from d
. In the second everything would happen just as you would normally expect.
from jsx.
Are you saying I can just pass an array to createFragment
and it will accept it, keying by the index, with no extra effort from the developer's side?
from jsx.
@quassnoi Honestly not sure, but you could easily have a wrapper that does it, it's trivial logic.
from jsx.
Related Issues (20)
- Add early error to disallow invalid adjacent JSX elements HOT 3
- can you provide a syntactic sugar? HOT 3
- Can we move JSX to be an extension of ES Spec that evolves forward like EcmaScript + TC39 ? HOT 3
- RFC: An evolved JSX 2.0 proposal HOT 1
- Get accessor in props HOT 1
- HTML and JSX spec HOT 1
- The syntax in website is missing JSXFragment as JSXChild
- Proposal: ability to return multiple chlidren by auto-wraping them into a Fragment HOT 2
- Proposal: using ! prefix on attributes to set them to `false`
- Ambiguous syntax HOT 2
- Spec out whitespacing / line break behaviors HOT 4
- Split Out Lexical Grammar
- Behavior of `�` and lone surrogates unicode entities HOT 2
- Proposal: Attributes with the same name as their value HOT 1
- Proposal: Syntactic sugar for props with same name as value passed HOT 1
- Distinguish tags from elements in the terminology
- Feature request: nameless closing tags
- Proposal: faster way to id and classes HOT 7
- Proposal: combining classes using only className HOT 2
- In this specification there is a reference to Babylon, now @babel-parser
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 jsx.