Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Lightning-Fast Mobile App Development with Galio

You're reading from   Lightning-Fast Mobile App Development with Galio Build stylish cross-platform mobile apps with Galio and React Native

Arrow left icon
Product type Paperback
Published in Nov 2021
Publisher Packt
ISBN-13 9781801073165
Length 272 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Alin Gheorghe Alin Gheorghe
Author Profile Icon Alin Gheorghe
Alin Gheorghe
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Chapter 1:Introduction to React Native and Galio 2. Chapter 2: Basics of React Native FREE CHAPTER 3. Chapter 3: The Correct Mindset 4. Chapter 4: Your First Cross-Platform App 5. Chapter 5: Why Galio? 6. Chapter 6: The Basics of Mobile UI Building 7. Chapter 7: Exploring the State of Our App 8. Chapter 8: Creating Your Own Custom Components 9. Chapter 9: Debugging and Reaching out for Help 10. Chapter 10: Building an Onboarding Screen 11. Chapter 11: Let's Build – Stopwatch App 12. Chapter 12: Where To Go from Here? 13. Other Books You May Enjoy

Importing your first component

Now, it's time for us to learn more about importing components. Importing is great because we can grab components from anywhere and use them in our app. I mean it – you could grab a component from anywhere on the internet.

First, let's see how the Text component we've been using got into our App.js file.

If we look above the App() function, we will see that the first lines of code are all imports of different components. Let's take a look at those and see if they're that complicated:

Figure 2.4 –  Imports displayed in the App.js file

Figure 2.4 – Imports displayed in the App.js file

It's pretty easy to read and to understand what exactly is going on here. Let's take the first line, for example. We're importing StatusBar from a package called expo-status-bar.

Why are we're doing that? In our App() function, you'll see that we've used a component called StatusBar.

For us to be able to use a specific component, we'll need to import it from a package or a defined path inside our project.

We can see an import from React but we can't find the React component anywhere inside our code; why is that? This is mostly because we need React to be able to use the React framework while creating all those components and writing JSX.

Underneath, we can see there are three different imports from a package called react-native. We can see StyleSheet, Text, and View. React Native comes packed with a lot of basic but really important implementations of native code for us to use in our React app.

We'll look at these core components in more detail in the next section, but you must understand the fact that those components were imported and then used inside our main function.

You can find packages online, so you could import them into your files easily by using npm. This is already installed with your Node.js configuration, so it's ready to use right now. We can search for packages on https://npmjs.com and easily install any of them with the npm i package-name command.

Right now, we'll focus on the components we received from react-native. We'll install more components in the following chapters but first, we need to learn how to use what we already have at our disposal and how we can build on top of that.

Let's start by importing some of the most important components and use them inside of our app. So, let's go to the third line in our App.js file. Between those brackets where we've imported StyleSheet, Text, and View, we'll add the Image, TextInput, and Button components.

Now, our line will look like this:

import { StyleSheet, Text, View, Image, TextInput, Button } from 'react-native';

Let's try to understand what the purpose of each component is and how we can use them inside our application.

You have been reading a chapter from
Lightning-Fast Mobile App Development with Galio
Published in: Nov 2021
Publisher: Packt
ISBN-13: 9781801073165
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image