So what is
React Native?
Let's start with the React part,
also known as
React.js
which is the name of that library and I do expect that you know what React.js is.
You don't have to be an expert in React.js
but you should know what React.js is.
Nonetheless, let's briefly summarize what it is so that we're on the same page.
It's a Javascript library for building user interfaces,
that's the official definition,
that is what React does in the end. It runs on Javascript and it's good at building user interfaces.
Typically, we use React in web development for building web apps but it's important to understand that
React itself,
the library actually makes no assumption about what we're building with it because it's actually another
library which you'll also use when you're building web apps with React that is responsible for rendering
something onto the screen
and that's the React DOM library.
Now in every React for web project you're working on, you will call ReactDOM.render at some point of
time and hand off the React app to that method to actually render something onto the screen
and that's the library that knows about the web and knows how to render HTML elements and so on. React
itself is platform-agnostic,
it's just a library that's good at building trees of components, of finding out whether something changed,
if something needs to be re-rendered, of managing state, of passing data around
but it does so in an abstract way which is why you can use React on any platform.
You're not restricted to the browser, to HTML, to the web,
you can use the logic React gives you anywhere, it's the React DOM part that then knows how to work with
HTML and so on and that is super important to understand because that's important when we think
about React Native. React Native is a separate library which in the end is a collection of special React
components it gives you, so a collection of components you can use in your React app and these components
are special because React Native actually knows how to translate them, how to compile these components
to native widgets for iOS and for Android. So React Native kind of is like React DOM, it knows how to
talk to native platform, to Android and iOS and how to render native widgets and it gives you a bunch of
these widgets as React components so that you can build a user interface with these compilable components
so to say because you won't be able to use your regular divs and h1 and paragraph tags in React Native
apps because there are no direct equivalents for that in native code but I'll come back to that. Now
besides giving you these components, React Native is a bit more than that, it also gives you access to
some native platform APIs, for example it helps you use the device camera,
so things like that, common tasks you would want to do in native apps and in general, React Native gives
you tools to connect Javascript code to native platform code because you typically build a React Native
app by mostly writing Javascript code or depending on the app you're building, by entirely writing Javascript
code.
Now I say mostly, at least that's a possibility because you can also write native code for iOS or Android
and React Native gives you the tools to connect your Javascript code to that native code, though that's
a bit more advanced and in many apps, you will never need that and therefore, React Native gives you full
flexibility, it gives you a way of connecting Javascript to native code and it also gives you a lot of
pre-built native features which are conveniently usable from inside your Javascript code.
So if you then combine React Native and the features that gives you with React.js which knows how to
update a user interface and how to control a user interface, then you get everything you need to
compile a real native mobile app and that's also what React Native gives you, it gives you everything
you need to then take your Javascript code and compile that to a real native mobile app which you can
then ship to the App Store for iOS or to the Google Play Store for Android,
so you get a real native mobile app as a result in the end.