Learning React Native, Chapter 2: Working With React Native

How React Native Works?

React works with a virtual DOM.  React computes the necessary changes in memory, and only refreshes the DOM when necessary.  React Native works in a similar fashion.  The virtual DOM is replaced with Native objects on the mobile platform.  There is nothing special about Android, iOS, or the web.  Those are the bridges that existed in React Native.  People have written bridges for Linux, OSX, and Windows.

Rendering Lifecycles

The page renders, components are mounted to the DOM, and then React Components are rendered.  When a state or props changes, the difference is computed in the Virtual DOM, and React renders the new components.

Creating Components in React Native

React Native components are largely the same as the React Components

Working With Views

Instead of using HTML elements, you use platform specific components for React Native.  The most basic which is similar to a
in HTML.  

Using JSX

JSX is a combination of markup and JavaScript.  Instead of separating technologies (CSS, HTML, JavaScript), JSX separates concerns.

Styling Native Components

When using React on the web, we use CSS to style components, and we typically place these in their own files.  In React Native, we use inline styles.  React Native has utilities to make this easier.  It can be a quite a change from what you are used to as a Web Developer.

Host Platform APIs

React also has good support for native API's.  You won't have access to all the platform specific APIs.  In this case, you may have to write your own, or find components that others have written.  Host specific APIs can also your ability to reuse code.  It can be hard to reuse React Native code, if you are also writing for the web. 

Comments

Popular posts from this blog

Go Programming Blueprints, Chapter 2, Adding User Accounts

Successful Big Game Hunting Chapter 10