React Native Typescript Template doesn't work

前端 未结 2 1534
礼貌的吻别
礼貌的吻别 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: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

提交回复
热议问题