skip to Main Content

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

5

Answers


  1. Unless I’m wrong, npx react-native init your-project-name creates a JS project by default.

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
  3. 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.

    Login or Signup to reply.
  4. 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

    Login or Signup to reply.
  5. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search