Comments (8)
I don't know for sure to be honest but I don't think it really matters considering how uncommon this construct is used (in my experience)
from feliz.
Regarding the first bullet point and by extension #23/#24/#25, text
/innerText
is a shortcut helper specifically for inserting text, not a general "insert a child node" helper. The internal API of the React children prop does not apply, this is about the Feliz consumer API as an adapter layer in this case. So distinguishing it from prop.children
in some way seems appropriate, as does performing the standard string
conversion on the parameter given the text
name/intent of the helper.
from feliz.
I read over them again to be sure, but as far as I can tell, they are orthogonal to this issue.
text
/innerText
is a shortcut helper specifically for inserting text, not a general "insert a child node" helper.
Please correct me if I'm wrong, but it seems that's in fact exactly what it does. Raw strings (and numbers) are valid React children, and Feliz is simply making a children
prop with the input value (even though the documentation indicates otherwise).
Lines 59 to 60 in 51ec0c0
from feliz.
I don't think it is always good to strictly replicate the React API, in this case I chose for text
instead of children because I find it making more sense and easier to think about when you look for things:
- "I need to change the text of the button => I will try to find a property that has the word 'text' in it" 😍
- "I have to set the children of an element where it will have one child of type text because React children also takes a string and happens to be compatible" 😒
even though the documentation indicates otherwise
How is that so? The docs are saying that this is just a shortcut for children [ Html.text value ]
which ultimately results in the element having the content provided
from feliz.
Fair point :)
Re. the docs: You're right, the end result is the same.
I still suggest adding a string seq
overload to prop.text
, then, since AFAIK it may cause less re-renders than concatenating a string yourself and rendering that as a single node.
from feliz.
I still suggest adding a
string seq
overload toprop.text
, then, since AFAIK it may cause less re-renders than concatenating a string yourself and rendering that as a single node.
I don't it makes a lot of sense for prop.text to accept string seq
. if you are reading through the overloads of prop.text
and you see string seq, what would you think? Again in React primitives but who actually uses that and isn't that just a convenience helper to make JSX work properly? I would rather wait for a good use-case with examples to re-open the issue and implement it than trying to mimic the React API 1-to-1
from feliz.
it may cause less re-renders
It won't cause less re-renders, it will save you the computation of concatenation (which React will do anyways)
from feliz.
IIRC the reason it will save re-renders is because React will re-use the already rendered nodes for unchanged strings. Can't remember where I picked that up, it's a long time ago... So I might misremember. Is it incorrect?
from feliz.
Related Issues (20)
- Issue version 3.10.0 when using another Router component in the inner component
- IReactProperty Question HOT 1
- Q: interesting
- add vitest to template
- useElmish vs useReducer HOT 4
- Feedback on missing docs for newcomers HOT 1
- ReactComponentAttribute for props list HOT 2
- Q: Documentation on breaking changes in 2.6? [WAS Updating Feliz.UseListener to Feliz 2.6.0] HOT 4
- CSS overflow-anchor property HOT 1
- Error with Feliz 2.7 HOT 2
- Making UseElmish's dispatch function stable
- Feliz.Markdown escapeHtml doesn't seem to work HOT 1
- UseElmish: Failed to resolve import "use-sync-external-store/shim" HOT 3
- `react-markdown` removes the `escapeHtml` property HOT 1
- Clarification and Potential Improvement on PR #480 useEffectOnce behavior HOT 5
- Expanding Feliz.Rechart HOT 3
- Component created with a forwardRef that has generic type parameters loses state HOT 2
- "Directory import use-sync-external-store\shim is not supported" in UseElmish.fs.js HOT 2
- Use with Elmish documentation is lacking integration HOT 2
- Enhance Handling of F# Record Types as Props in ReactComponent Attribute HOT 4
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 feliz.