-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
[Discussion] React native without jsx #1474
Comments
Hmm... one of the benefit of using JSX is to write a very complex component in a declarative way. So I don't mind having a JSX compiler. React and React-Native have other things in commons. Such as Component Life Cycle, triggering and registering events, and architecture. So in my point of view, having a DOM namespace make sense to differentiate the Web and Mobile devices. I'd love you hear from other people. |
@alinz Without JSX, it can be declarative too in CoffeeScript. It's just an alternative. Thanks for the points in second paragraph. |
cc @vjeux because of this post: http://blog.vjeux.com/2013/javascript/react-coffeescript.html |
Why do you need React.DOM? |
Because I don't need to create short-hand factory functions for each component when I want to use them declaratively without JSX. The name of |
You can do
to use React Native without JSX |
You could do at the top of the files,
Not as pretty but still quite elegant |
Providing React.DOM doesn't really solve the problem because there's still the problem of creating elements for third-party components. Probably best to write your own helper like this: var {
View,
Text,
} = require('create-react-factories')(require('react-native')) |
@vjeux As you said, it's not pretty... As you have more components, the clutter @ide The built-in components are used far more often than third-party components. So, it's very convenient to have React.DOM. Third-party components should usually be used in one place (if a third party component is used everywhere, probably we should incorporate in core), so using |
@vjeux and co. have the final say but I don't think it makes sense to add this to the core for a couple reasons. It's confusing if core components behave differently even though they otherwise look the same as third-party components. Also while totally ubiquitous components like Text and View belong in core, the majority of the other components in this repo aren't very different from third-party components. It's better for the ecosystem if a solution for MapView applies to react-native-camera's Camera too. |
@ide Sorry, I don't quite understand. Why would adding I don't see much problem with the namespace thing: |
Take a handful of components: View, Image, Camera, ListView. It's not intuitive to identify which ones let you write
My point is that I wouldn't be able to tell you that ListView or Navigator are first-party components while Camera or Video are third-party components without background knowledge. There's nothing intrinsic to these components that warrants a different syntax for constructing them. Something like React.DOM adds a second syntax for a use case that can be addressed with a helper module in a pretty straightforward way ( |
Um... Mixing JSX and non-JSX is a bad practice. When
Again, mixing JSX and non-JSX is a bad practice. If someone sticks to JSX, all components should be imported from As the title of this issue says, it's about using react native without JSX. And also having For the use cases, providing |
This is a good idea. I just think it should be applied uniformly across all composite components. I'm not proposing to mix JSX and non-JSX; what I'm trying to say is that mixing uppercased composite-component classes and composite-component factories makes things more confusing. Maybe there should be lowercased |
Hi there! This issue is being closed because it has been inactive for a while. But don't worry, it will live on with ProductPains! Check out it's new home: https://productpains.com/post/react-native/discussion-react-native-without-jsx |
In case anyone ends up on this issue (as I did) looking for a nice way of creating react-native components without JSX, you may want to check NJSX. |
We can use react.js without jsx (http://facebook.github.io/react/docs/displaying-data.html#react-without-jsx), but there is currently no implementation for
React.DOM
in react native.I have my own implementation now, which allows me to do the following thing in CoffeeScript:
I'd love to see react native being consistent with react by providing
React.DOM
or a better name thanDOM
?I'd love to contribute this if we agree with this point (and I hope so).
React.DOM
will include all current components. And which folder should theReact.DOM
code go?The text was updated successfully, but these errors were encountered: