Giter Site home page Giter Site logo

ashirbadgudu / react-native-typescript-stater Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 0.0 3.93 MB

A react native typescript stater project with with all the types of navigation with proper types and folder structure

JavaScript 1.51% TypeScript 87.38% Ruby 2.02% Java 6.41% Objective-C 2.03% Objective-C++ 0.66%
bottom-navigation drawer-navigation native-base react-native react-navigation react-navigation-v6 typescript hacktoberfest2022

react-native-typescript-stater's Introduction

React Native Typescript Setup

Setup Navigation

Install Navigation Packages

yarn add @react-navigation/native
yarn add react-native-screens react-native-safe-area-context

Install Pod for above dependencies

cd ios && arch -x86_64 pod install

Set up react-native-screens by updating android/app/src/main/java/<your package name>/MainActivity.java file

import android.os.Bundle;

public class MainActivity extends ReactActivity {
  // ...
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(null);
  }
  // ...
}

Install stack navigation

yarn add @react-navigation/native-stack

Wrap the navigation with navigation container

import React from 'react';
import {NavigationContainer} from '@react-navigation/native';

export default function App() {
  return (
    <NavigationContainer>{/* Rest of your app code */}</NavigationContainer>
  );
}

Install Drawer Navigation package & other dependencies

yarn add @react-navigation/drawer react-native-gesture-handler react-native-reanimated
cd ios && arch -x86_64 pod install

Setup react-native-gesture-handler in index.js

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

Settings up react-native-reanimated/plugin

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: ['react-native-reanimated/plugin'], // this line add
};

Reset the server cache

yarn start --reset-cache

Install Bottom Navigation package

yarn add @react-navigation/bottom-tabs

Setup absolute imports

Install babel-plugin-module-resolver

yarn add -D babel-plugin-module-resolver

Update the babel.config.js file

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    [
      'module-resolver',
      {
        root: ['./src'],
        alias: {
          '~/assets': './src/assets',
          '~/components': './src/components',
          '~/components/core': './src/components/core',
          '~/components/containers': './src/components/containers',
          '~/components/shared': './src/components/shared',
          '~/configs': './src/configs',
          '~/constant': './src/constant',
          '~/hooks': './src/hooks',
          '~/routes': './src/routes',
          '~/screens': './src/screens',
          '~/styles': './src/styles',
          '~/types': './src/types',
        },
      },
    ],
  ],
};

Update tsconfig.json file

{
  "extends": "@tsconfig/react-native/tsconfig.json",
  "compilerOptions": {
    "baseUrl": "./src",
    "paths": {
      "~/*": ["*"]
    }
  }
}

Install lottie animation library

yarn add lottie-react-native [email protected]

Install Image Picker library

Install react-native-image-crop-picker library

yarn add react-native-image-crop-picker

Update permissions in AndroidManifest.xml file for android

<!-- Camera permission required to access picture from camera -->
<uses-permission android:name="android.permission.CAMERA" />

Update permission in info.plist for ios

<key>NSPhotoLibraryUsageDescription</key>
<string>This app uses the gallery to update photo of your profile</string>
<key>NSCameraUsageDescription</key>
<string>This app uses the camera to take pictures for updating profile photo</string>

Add Custom Font Family To Your Application

Create a file named react-native.config.js

module.exports = {
  project: {
    ios: {},
    android: {},
  },
  assets: ['./src/assets/fonts'], // path to the fonts directory
};

Run the following command to add all the assets to both the platforms

npx react-native-asset

Install vector icons

Install react-native-vector-icons and its types

yarn add react-native-vector-icons
yarn add -D @types/react-native-vector-icons

For android open android/app/build.gradle and add following

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

Update following in info.plist for ios

<key>UIAppFonts</key>
<array>
  <string>AntDesign.ttf</string>
  <string>Entypo.ttf</string>
  <string>EvilIcons.ttf</string>
  <string>Feather.ttf</string>
  <string>FontAwesome.ttf</string>
  <string>FontAwesome5_Brands.ttf</string>
  <string>FontAwesome5_Regular.ttf</string>
  <string>FontAwesome5_Solid.ttf</string>
  <string>Foundation.ttf</string>
  <string>Ionicons.ttf</string>
  <string>MaterialIcons.ttf</string>
  <string>MaterialCommunityIcons.ttf</string>
  <string>SimpleLineIcons.ttf</string>
  <string>Octicons.ttf</string>
  <string>Zocial.ttf</string>
  <string>Fontisto.ttf</string>
</array>

Install Pod

cd ios && arch -x86_64 pod install --repo-update && cd ..

react-native-typescript-stater's People

Contributors

ashirbadgudu avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.