Reputation: 121
I'm beginner for react native i'm creating a React Native Project using React native CLI but project is creating with app.ts i want to create project in javascript version.
i have tried react native official docs to create React native Project
Upvotes: 12
Views: 13357
Reputation: 1
I faced the same issue because the latest default template for React Native with Expo comes with TypeScript. When we use npx create-expo-app@latest
, as mentioned in the React Native documentation, it sets up a project with TypeScript. If you want the usual JavaScript template when creating a React Native project with Expo, you can use the command
npx create-expo-app my-app --template expo-template-blank
In the above command, please change my-app
to your desired app name.
Upvotes: 0
Reputation: 31
I also faced the same problem but it's all good, you just have to use "npx create-expo-app@latest --template" the choose the blank option.
you are welcome
Upvotes: 3
Reputation: 59
React native of >=0.71
version considers Typescript as default. You can change .tsx
file to .js
file by changing the file extension and deleting the typescript codes from the file.
But react native <=0.70
version still considers JavaScript as default. To install react native of <=0.70
you can use the following command on CLI:
$ npx react-native init <project_name> --version 0.70
Here you can write the version you want.
Upvotes: 3
Reputation: 610
As mentioned above New React Native projects target TypeScript by default, but also support JavaScript and Flow.
New projects created by the React Native CLI or popular templates like Ignite will use TypeScript by default.
TypeScript may also be used with Expo, which maintains TypeScript templates, or will prompt you to automatically install and configure TypeScript when a .ts or .tsx file is added to your project.
However, JavaScript may still be used. Files with a .jsx extension are treated as JavaScript instead of TypeScript, and will not be typechecked. JavaScript modules may still be imported by TypeScript modules, along with the reverse.
Reference : Getting Started with TypeScript
Upvotes: 0
Reputation: 13
React native latest version comes with typescript support by default ( version >= 0.71 ) https://reactnative.dev/blog/2023/01/03/typescript-first But if you want to use js , just convert the extension to .js or .jsx
Upvotes: 1
Reputation: 998
There was an update recently and all new React Native projects are going to be created with TypeScript by default, but they also support JavaScript.
Project files with a .jsx
.js
extension are treated as JavaScript instead of TypeScript, and will not be typechecked. This means, you can create projects files as .jsx
or .js
and your project is going to work as expected.
If you want to create project with TypeScript files, but skip the typechecking, you can add // @ts-nocheck
onto the top of each TypeScript files. However, this is not advised, it just gets rid of red lines in your IDE, without checking types in the project file.
Upvotes: 3
Reputation: 4635
TypeScript is a language which extends JavaScript by adding type definitions. New React Native projects target TypeScript by default, but also support JavaScript and Flow.
Files with a .jsx
/ .js
extension are treated as JavaScript instead of TypeScript, and will not be type checked.
So you can simply use JavaScript instead of TypeScript by changing extension from .tsx
/.ts
to .jsx
/.js
and also you may remove type annotations if any is there in your JavaScript files.
Ref : Using JavaScript Instead of TypeScript
Upvotes: 13
Reputation: 21
Unless I'm wrong, npx react-native init your-project-name
creates a JS project by default.
Upvotes: -5