Search code examples
typescriptreact-nativereact-native-web

How to use react-native-web with Typescript


I've created the application using create-react-native-app. Commands which I use to run and make production build are:

"scripts": {
  "web": "react-scripts start",
  "build": "react-scripts build"
}

For react native I can use react-native-scripts-ts, but how to configure Typescript pipeline with react-native-web?


Solution

  • So the solution is to use:

    "scripts": {
        "test": "jest",
        "web": "react-scripts-ts start",
        "build": "react-native-scripts-ts build",
        "test:web": "react-scripts test --env=jsdom",
        "eject": "react-scripts eject"
      },
    

    And run App.tsx with:

    AppRegistry.registerComponent("root", () => App);
    AppRegistry.runApplication('root', { rootTag: document.getElementById('root') });