Comments (5)
The React docs specify that because of the JSX transform logic, not for any internal reason. Take this example:
<foo className="bar baz">qux</div>;
In JSX, it's ambiguous whether the above example should result in creating a React Element using some foo
variable (and throw an error if it can't be found), or if it should result in creating a React Element using the string "foo" which the renderer (e.g. react-dom, react-native) knows how to turn into a "native" element.
So the JSX transform has a requirement that all of your components variable names start with UpperCase so that it's unambiguous whether it ought to pass a string to createElement
or a variable.
In Helix, we have no such ambiguity because we pass in the exact type we want to create in when creating an element
($ "div") ;; native element
($d "div") ;; native element with DOM prop transformations
($ div) ;; passing in a component bound to the symbol `div`
($d div) ;; passing in a component bound to the symbol `div` with DOM prop transformations
The helix.dom
helper macros emit ($d "div")
etc.
So we can name our components whatever we want.
For your issue with react-navigation, I would consider opening a ticket with them.
As far as I can tell after skimming the JS source, there's no difference in behavior using a component that starts with an Uppercase vs lowercase other than the warning. I don't know why they took it upon themselves to warn their users, when anyone using JSX should have other ways of being notified about best practices when using that syntax. You can also feel free to ignore the warning.
If the warning is bothering you, you can always name the components you pass to it using an UpperCase name, like
(defnc MyFeature
[props]
,,,)
which should get rid of the warning as well.
from helix.
Thank you for the detailed reply! I will open an issue with react-navigation and reference this one.
Unfortunately(defnc UpperCaseName ..)
doesn't even work because the component function's .-name
becomes the fully qualified namespace name ("myapp$foo$UpperCaseName_render"
), so we would need our root namespace to also be capitalized in order to avoid this warning.
from helix.
aha right 😅. you could manually set the name
property then
(defnc my-component
[props]
,,,)
(set! (.-name my-component) "MyComponent"))
For me, I'd probably just ignore the warning, unless it was really obnoxious.
from helix.
Seems like (on react-native at least), (set! (.-name my-component) "MyComponent"))
does not have an impact on (.-name my-component)
. Perhaps name
is some kind of special javascript property?
I was able to get this to use via js/Proxy
, but I was worried about what unexpected issues could be caused by swapping a component for a proxied object.
from helix.
For anyone else looking into this issue, I was going to submit an issue to react-navigation, but I failed to reproduce this in a javascript Snack:
https://snack.expo.dev/@aiba/incorrect-warning-repro
I give up.
from helix.
Related Issues (20)
- gensym / anonymous function syntax breaks fast refresh HOT 2
- Include resources in deps.edn :paths
- $ clj-kondo hook fails to lint & right when component is not a symbol
- The $ macro and new JSX transform HOT 14
- `wrap-fx` is public HOT 1
- Wrappers for useTransition, useDeferredValue, etc. HOT 1
- Is it possible to bypass the camel-casing of properties? HOT 7
- Add wrapper around createRef with atom protocols HOT 2
- How to use with uikit? HOT 2
- Running tests in nodejs with jsdom HOT 4
- Companies using Helix HOT 1
- indent metadata on helix.dom macros HOT 3
- Create use-isomorphic-layout-effect HOT 6
- Make self-hosted CLJS compatible HOT 2
- Fix indentation with CIDER HOT 3
- Release request HOT 1
- Warning: React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead. HOT 2
- `helix.dom/tags` removed HOT 2
- defnc taking pre- & post-conditions HOT 1
- Release request HOT 1
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 helix.