Code Monkey home page Code Monkey logo

react-native-typescript-boilerplate's Introduction


Friday App

๐Ÿš€ Friday App ๐Ÿš€

Build enterprise React Native apps

React Native Template - TypeScript

Travis Code Climate iOS and Android License PRs Welcome Code Size Releases

An opinionated React Native Starter Kit with React Native Navigation + Redux + Airbnb TSLint to build iOS and Android apps using TypeScript

The project has been setup based off RN Getting Started and instructions from Microsoft's Github TypeScript React Native Starter repo.

React Native Typescript Boilerplate


Supports React 17, React Native 0.66.0, React Native Navigation v7, Flipper and Hermes

Update (Nov 2021):

  • Added Types (actions, reducers, store, components and more).
  • Core API service using fetch
  • Support for M1
Updates RNN RN React Comments
Nov '21 7.23.1 0.66.0 17.0.2 Type definitions
May '21 7.14.0 0.64.1 17.0.1 Update RN RNN, Hermes Support
Oct '20 7.1.0 0.63.3 16.13.1 Support for Flipper
Apr '20 3.7.0 0.61.5 16.9.0 Support for RN > 0.60, Android X
Nov '19 2.26.2 0.59.10 Maintenance
Mar '19 2.13.1 0.58.6 16.8.4

Sponsor

I will keep supporting the projects that I have open sourced. If you have used any of my projects, for yourself or your business, I'd love your support through Github sponsors. You can also try to convince your employer to sponsor as a business.

Introduction

Jumpstart building robust apps using React Native and TypeScript with most commoly needed tools already setup. Just yarn install and get going from respective IDEs.

  • Routing and Navigation
  • State Management using Flux Architecture
  • Atomic Design pattern
    • The structure of the app is inspired by atomic design pattern.
    • Widgets / Elements: Build your own Design Language System with these building blocks.
      • Typography: Base Typography setup - Color, Font, LAYOUT, CTA, FONTS, TEXT, TEXT_INPUT
      • elements: <BUTTON_DEFAULT> or <CTEXT>. They are custom elements that have default properties like font, size and so on.
      <CTEXT style={GLOBAL.CTA.Style.primaryText}>{title}</CTEXT>
      • widgets: Any component providing a complete functionality. E.g. carousels component, banner component, etc.
      <Category componentId={componentId} title={locale.Categories} />
  • Type Definitions
    • Type definitons for actions, reducers, store, components and more.
  • Built-in Splash screen
  • Hermes and Flipper integrations
  • Code Lint
App Screens
Splash Home Side Menu
Flipper Support

Flipper

Table of Contents

Project Structure

/
โ”œโ”€โ”€ android						Android Native code
โ”œโ”€โ”€ ios							iOS Native Code
โ”œโ”€โ”€ shared
โ”‚   โ”œโ”€โ”€ redux					Applications Logic
โ”‚   โ”‚   โ”œโ”€โ”€ constants
โ”‚   โ”‚   โ”œโ”€โ”€ actions
โ”‚   โ”‚   โ”œโ”€โ”€ api
โ”‚   โ”‚   โ”œโ”€โ”€ reducers
โ”‚   โ”‚   โ”œโ”€โ”€ store
โ”‚   โ”‚   โ””โ”€โ”€ thunk
โ”‚   โ””โ”€โ”€ utilities
โ”‚   โ”œโ”€โ”€ services
โ”‚   โ”‚   โ”œโ”€โ”€ core				Core Services - API (fetch/axios), storage
โ”‚   โ”‚   โ”‚  โ”œโ”€โ”€ API
โ”‚   โ”‚   โ”‚  โ””โ”€โ”€ Storage
โ”‚   โ”‚   โ”œโ”€โ”€ home
โ”‚   โ”‚   โ””โ”€โ”€ search
โ”œโ”€โ”€ src
โ”‚   โ”œโ”€โ”€ config					Global Configuration
โ”‚   โ”œโ”€โ”€ constants				Screen names and ids, Localization
โ”‚   โ”œโ”€โ”€ navigators				Router, Navigation
โ”‚   โ”œโ”€โ”€ view					UI compoments
โ”‚   โ”‚   โ”œโ”€โ”€ elements				Custom elements
โ”‚   โ”‚   โ”œโ”€โ”€ assets
โ”‚   โ”‚   โ”œโ”€โ”€ screens
โ”‚   โ”‚   โ”œโ”€โ”€ styles				Typography
โ”‚   โ”‚   โ””โ”€โ”€ widgets				Custom components
โ”‚   โ””โ”€โ”€ utilities
โ”œโ”€โ”€ __tests__					Unit Tests
โ”‚   โ”œโ”€โ”€ presentation
โ”‚   โ””โ”€โ”€ redux
โ”œโ”€โ”€ .babelrc
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ .travis.yml					Travis CI
โ”œโ”€โ”€ tsconfig.json				TypeScript Configuration
โ”œโ”€โ”€ tslint.js					TSLint configuration - extending AirBnb
โ”œโ”€โ”€ tsconfig.json
โ”œโ”€โ”€ app.json
โ”œโ”€โ”€ index.js					Application Entry point
โ”œโ”€โ”€ package.json
โ””โ”€โ”€ README.md

shared Everything related to application business logic. The redux store.

src Presentation layer for the app - screens, styles, images, icons etc.

Getting Started

Make sure node version installed is >=12.x.x. Then install using yarn (or npm):

yarn install

Start the Metro Bundler:

yarn start
iOS

One time. Move to ios folder and install pods:

cd ios && pod install

Launch application from XCode (Command + R) Or launch from Terminal:

yarn ios
# runs the following command. change device name here
# `npx react-native run-ios --simulator='iPhone 11'`
Android

Start an Android Simulator from:

Android Studio > Tools > AVD Manager > Run any device

Similarly, run from Android Studio itself Or from Terminal:

yarn android
# runs the following command
# react-native run-android --variant=Debug

Commands

Remark
yarn start Starts metro bundler
yarn ios Starts iOS app. Start metro bundler first
yarn android Starts Android app. Start metro bundler and Android emulator first
yarn lint linting
yarn lint:fix tries to fix linting issues automatically
yarn build:android:debug Android debug build
yarn build:android:release Android release build

Cheat Sheet

iOS Launch Screen

XCode -> Project Folder -> Click on `Images.xcassets` -> Click on `LaunchScreen`

Change the 3 images here to set the new launch screen for iOS.

Launch Screen

Android Launch Screen

`./android/app/src/main/res/drawable-*` folders

Change the images the drawable-* folders to set the new launch screen for Android.

M1 support

Some additional steps may be required for project to work on M1.

  • Disable Rosetta in Terminal
  • Install ffi
sudo arch -x86_64 gem install ffi
  • Re-install dependencies
arch -x86_64 pod install

Now try and run CocoaPods.

P.S.: Thanks to samanthadotcom#7043 (discord)

Single Screen vs Tabbed Based Navigation

The application launches with a splash screen, and then moves to a tabbed based navigation. Splash screen is a good place to fetch data / build application launch logic like getting user token from API or Async Store, load persist state etc.

For Single screen application, replace this tabbed based navigation with a single screen - just home, or simply use the splash screen to setup the app, may be with a burger menu.

Renaming the App

You might also want to rename the app for your own use. Follow any of the links below.

Or

Contributing

Please check out Contributing.

Authors

See also the list of contributors.

react-native-typescript-boilerplate's People

Contributors

a7urag avatar amitm30 avatar brianjvarley avatar dependabot[bot] avatar nelsonomuto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-typescript-boilerplate's Issues

Build script for iOS

It would be great if an npm script would be there for ios ipa build. (without the need of a mac and xcode).

Android Metro Bundler - Connected Mode Fix

Describe the bug
The android application when it starts, is not connected to the metro bundler and so that changes are not reflected in live mode.

Expected results

This should be connected and auto-reload on code changes to js files.

Problem renaming project

Describe the bug
I'm getting the error "Application myApp has not been registered" when I try to rename the app following the linked renaming guide.

Steps to reproduce

  1. Downloaded the boilerplate
  2. npm install
  3. deleted android/ and /ios
  4. react-native eject
  5. react-native link
  6. react-native run-android

Problem running project on Android

Problem running project on Android

java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so caused by: couldn't find DSO to load: libglog_init.so caused by: couldn't find DSO to load: libglog.so caused by: couldn't find DSO to load: libgnustl_shared.so caused by: dlopen failed: "/data/data/com.fridayapp/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit
at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:703)
at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:564)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:500)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:455)
at com.facebook.react.bridge.ReactBridge.staticInit(ReactBridge.java:18)
at com.facebook.react.bridge.NativeMap.(NativeMap.java:19)
at com.facebook.react.bridge.JSCJavaScriptExecutorFactory.create(JSCJavaScriptExecutorFactory.java:21)
at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:917)
at java.lang.Thread.run(Thread.java:764)

tslint.js files throws a syntax error running yarn lint on windows

Describe the bug
A clear and concise description of what the bug is.

On the master branch after a successful run of yarn of this project. The yarn lint or yarn lint:fix commands fail on my windows machine. A syntax error is thrown classed as a "Microsoft JScript compilation error". (see attached screenshot)

It looks to be a Windows specific issue where this tslint.js is being run by windows instead of node when called in package.json - similar to this SO question: https://stackoverflow.com/questions/37192508/trying-to-execute-a-script-from-package-json-on-windows-throws-a-jscript-error

Expected results

What did you expect to happen?

The yarn lint command would run to completion and lint the project source files.

Observed results

The yarn lint command throws a syntax parse error on Windows machine, pointing to the tslint.js file as the culprit. This is run straight after cloning and yarn install without any modification to the original code.

What happened?

Logs

Run react-native info in your terminal and paste its contents here.

$ react-native info

  React Native Environment Info:
    System:
      OS: Windows 7
      CPU: (4) x64 Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz
      Memory: 3.22 GB / 7.88 GB
    Binaries:
      Yarn: 1.13.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
      npm: 5.6.0 - C:\Program Files\nodejs\npm.CMD
    IDEs:
      Android Studio: Version  3.3.0.0 AI-182.5107.16.33.5199772

Steps to reproduce

$ nvm list

  * 8.11.4 (Currently using 64-bit executable)
    8.11.2
    8.10.0

$ nvm use 8.11.4

$ yarn

$ yarn lint
yarn run v1.13.0
$ tslint --project ./tsconfig.json
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Throws the following syntax parse error on Windows:

image

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.