Can I use JavaScript in React Native?
React Native runs on React, a popular open source library for building user interfaces with JavaScript. To make the most of React Native, it helps to understand React itself. This section can get you started or can serve as a refresher course. Show We’re going to cover the core concepts behind React:
If you want to dig deeper, we encourage you to check out React’s official documentation. Your first componentThe rest of this introduction to React uses cats in its examples: friendly, approachable creatures that need names and a cafe to work in. Here is your very first Cat component:
Here is how you do it: To define your
Your component starts as a function: You can think of components as blueprints. Whatever a function component returns is rendered as a React element. React elements let you describe what you want to see on the screen. Here the
You can export your function
component with JavaScript’s
Now take a closer look at that JSXReact and React
Native use JSX, a syntax that lets you write elements inside JavaScript like so: Any JavaScript expression will work
between curly braces, including function calls like You can think of curly braces as creating a portal into JS functionality in your JSX!
Custom ComponentsYou’ve already met React Native’s Core Components. React lets you nest these components inside each other to create new components. These nestable, reusable components are at the heart of the React paradigm. For example, you can nest Developer notes
|