Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

No cookies to display.

Create a new Expo project with TypeScript in React Native

Tiempo de lectura: 2 minutos
Today we are going to learn how we can create a new React Native project with Expo.

Creating a new project with React Native, Expo, and TypeScript is a relatively straightforward process. Here are the basic steps you can follow:

Step 1: Install Node.js and npm

Make sure you have Node.js and npm installed on your machine. You can download them from the official Node.js website: https://nodejs.org/

Step 2: Install Expo CLI

Install Expo CLI globally using the following command in your terminal:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
npm install -g expo-cli
npm install -g expo-cli
npm install -g expo-cli

Step 3: Create a New Project with TypeScript

Run the following command to create a new React Native project with TypeScript:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
npx create-expo-app -t expo-template-blank-typescript
npx create-expo-app -t expo-template-blank-typescript
npx create-expo-app -t expo-template-blank-typescript

If it asks to install create-expo-app@2.1.1, press y.

Now it asks for the application name:

Write the name and wait while it creates the project.

And it’s ready:

Now it is recommended to add this inside package.json

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
{
"scripts": {
"ts:check": "tsc"
...
}
}
{ "scripts": { "ts:check": "tsc" ... } }
{
  "scripts": {
    "ts:check": "tsc"
    ... 
  }
}

Ending up like this:

This is used to check TypeScript, we can use this command:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
npm run ts:check
npm run ts:check
npm run ts:check

Now let’s generate the **tsconfig.json** file responsible for checking TypeScript:

Paso 4: Navegar al directorio del proyecto

Ingresa al directorio de tu proyecto recién creado:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
cd myReactNativeApp
cd myReactNativeApp
cd myReactNativeApp

Paso 5: Run the project:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
expo start
expo start
expo start

This command will open a new window in your browser with the Expo interface. From here, you can launch your app on an emulator or physical device.

Step 6: Develop with TypeScript

Now you can start developing your application using TypeScript. TypeScript files have the .tsx extension, and Expo has already set up TypeScript for you in this project.

Step 7: Other Useful Tools

  • Visual Studio Code (VSCode): I recommend using VSCode as your code editor. You can also install the “React Native Tools” extension for a better development experience.
  • Expo Go: You can download the Expo Go app on your device to test your app on a physical device.
0

Leave a Comment