Code Monkey home page Code Monkey logo

react-native-ts-template's Introduction

reactNativeTSTemplate

Describes instructions for building a React Native application using TypeScript.

Installation

In the root directory, running npm install would install all the dependencies.

tsconfig.json

For setting up TypeScript with React Native, the jsx flag needs to be set to react-native. All the typescript code could be organized inside a single folder (ts), and the resultant javascript code can be organised inside another folder (js). These folders can be mentioned in the rootDir and outDir flags respectively.

Run tsc in watch mode

tsc -w would run the typescript compiler in watch mode, monitoring the rootDir for any changes and instantly compiling to outDir.

To build the app on an Android device

During the first run, all the packages need to be installed. So in the root folder, run:

  1. npm install
  2. npm install -g react-native (in case react-native does not exist)
  3. react-native link would link the required assets to the project
  4. react-native run-android (this command should install the app on your device, with the assumption that adb works on your system, and USB debugging has been enabled on your device)

To enable hot-reload of the application

Connect the physical device and run react-native run-android. In another terminal window, run react-native start, in the root folder. This would create a development server that creates incremental builds and deploys them on the device.

Also, once the app has loaded on the device, long press the menu key, and an alert window would open with a bunch of option. Select Enable Hot Reloading in the menu. This should now automatically pick up any changes made to the js files (which at this point, would be compiled from ts/*.tsx files, if the typescript compiler is being run in the watch mode). If hot reloading doesn't work, reinstall the app using react-native run-android with react-native start still running. This should fix the issue. Now edit ts/app.tsx and see the changes live on your device.

Further instructions

To make the build process easier, use ts/app.tsx as the main file that exports one single function. This function can then be imported in index.android.js or index.ios.js. Thus, the index.*.js files need not be touched. All new functionality could be added in multiple source files in ts/ directory.

To create icons for different platforms

To create icons for different platforms, place your icon under resources folder in root directory or replace the existing icon.png with your file.

  1. npm install
  2. brew install imagemagick
  3. Cmd/Ctrl + Shift + P ~> This will open a task runner. Type task and choose Ship Icons from the options shown.
  4. Press enter as confirmation of your project name shown and then on asking permission for overwrite type y and hit enter.

react-native-ts-template's People

Contributors

apratheek avatar sarojk562 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

sarojk562

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.