skip to Main Content

so after installing react native using npx react-native init MyProject the project is running and open in emulator but the app file is not app.js instead app.tsx,

file strcuture

The question is i am new to react native and many tutorial i see is havgin App.js file, and the code in app.js is different between js and tsx at least that’s what i see, or is it just the same if i follow tutorial like folder structure, syntax and everything.

2

Answers


  1. That’s because of this

    New projects created by the React Native CLI or popular templates like Ignite will use TypeScript by default.

    Read Using JavaScript Instead of TypeScript

    You can just rename your tsx to jsx

    Login or Signup to reply.
  2. Well, I had the same concerrns earlier today while working on the current version 0.71. This version does not create a App.js file. What I did was- I created a file App.jsx and added this code:

    import { StyleSheet, Text, View } from 'react-native'
    import React from 'react'
    
    const hello = () => {
      return (
        <View>
          <Text>App</Text>
        </View>
      )
    }
    
    export default hello
    
    const styles = StyleSheet.create({})
    

    it automatically renders the code in it instead of the default App.tsx file
    You can write your JavaScript code in the Ap.jsx file

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