Hacker News new | past | comments | ask | show | jobs | submit login

Could you explain how React Native relates to React?



React began targeting the browser DOM. Now, React is actually the shared library used by both react-native and react-dom.

In React (in general) you build components out of other components. Thus react-dom contains pre-defined components named after HTML dom elements. They behave like a very standards-compliant and consistent dom implementation.

So if you want to build a name badge component in React for web, you'd define a "render" method that used the dom-oriented components.

With React-Native, there was no reason to implement a component called Div. Instead, the authors created one called View. Instead of copying the browser DOM's behavior they created simple components that are fairly direct abstractions of native UI toolkit components... Things like ListView, Modal, etc. To build something using React Native, you just compose these existing components to make your own components.

Tangent: Interestingly, you can use a library called react-native-web to render React Native components in a browser, which makes it very elegant to share code between web and mobile versions of an app. There are a few differences, but it lets your pure js components designed for native work perfectly on the web, so it's actually not a bad approach for building for the web... in some cases React Native's components contain behavior you'd end up implementing for web anyway.


React Native employs the React library. It's exactly the same except instead of using "web components" to construct user interfaces such as <div> and <span> elements, we use native components. For example, the React Native "View" component maps straight onto iOS's UIView and Android's android.view.

Check out the tutorial here for some basic examples: https://facebook.github.io/react-native/docs/tutorial.html


React is a conceptual framework which lays out how UIs are specified and how they behave (via the component model). Then when it comes to rendering the UI, the React framework allows several rendering targets (the classic one is React-DOM, which renders a DOM for web pages). React Native is a React renderer for iOS and Android apps.


I've never used it and don't really know much about it but from a quick reading it seems that React is about building reusable components in HTML, CSS, and JavaScript. React Native provides bindings to native components that you'd use in Objective-C/Swift on iOS or Java on Android.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: