React Native Typescript Template doesn't work

前端 未结 2 1495
礼貌的吻别
礼貌的吻别 2021-01-25 15:10

I have created a new project of React Native with a typescript template using the official command react-native init MyApp --template typescript (a couple of times

相关标签:
2条回答
  • 2021-01-25 15:31

    Seems like you didn't execute the post installation setup script which takes care of removing the App.js file. Anyway, that's not necessary anymore as with the release of React Native 0.59 the post installation setup script is being executed automatically.

    0 讨论(0)
  • 2021-01-25 15:40

    I have find the solution, and basically when you create the react native app using the typescript template in the ./ of your project apperar 2 files named App (App.js and App.tsx) so basically the solution to get this working is go to the index.js and replace

    import App from './App'; per import App from './App.tsx';

    index.js

    import {AppRegistry} from 'react-native';
    import App from './App.tsx';
    import {name as appName} from './app.json';
    
    AppRegistry.registerComponent(appName, () => App);
    

    Also you can solve the problem removing the .js file so the index will point to the .ts

    0 讨论(0)
提交回复
热议问题