Welcome to the third lesson of our course on Mobile App Development with React Native. In this lesson, we will delve into the basics of React Native, including JavaScript ES6 fundamentals and an introduction to JSX.
ES6, also known as ECMAScript 2015, introduced several changes to JavaScript that make it easier to work with and more powerful. Here are a few key features:
let
is block-scoped, and const
is block-scoped and read-only.${}
syntax.JSX stands for JavaScript XML. It is a syntax extension for JavaScript, recommended by React for describing the UI of the app. It might remind you of a template language, but it comes with the full power of JavaScript.
Here's an example of what JSX looks like:
const element = <h1>Hello, world!</h1>;
In the example above, the <h1>
tags are not HTML, but JSX. JSX produces React "elements", which are JavaScript objects that can be rendered to the DOM.
Components are the building blocks of any React application, and a typical React app will have many of these. Simply put, a component is a JavaScript class or function that optionally accepts inputs i.e. properties(props) and returns a React element that describes how a section of the UI should appear.
Here's an example of a functional component in React Native:
import React from 'react';
import { Text } from 'react-native';
const HelloWorld = () => {
return ( <Text>Hello, world!</Text> );
}
export default HelloWorld;
In the next lesson, we will dive deeper into React Native, exploring State and Props, Styling in React Native, and handling user input. Stay tuned!
Note: Familiarity with JavaScript and React will be beneficial in understanding this lesson.