Skip to content

A personal project to get myself well-versed with React Native.

Notifications You must be signed in to change notification settings

rajatdua/credcopy

Repository files navigation

Introduction

This is a project to get myself well-versed with React Native. It is a copy-cat of an application called "CRED", which is an Credit-Card payment application.

Bootstrapped with React-Native-Cli x TheCodingMachine (Custom)

  • yarn start - To start the Metro Bundler.
  • yarn android - To start Android build for a simulator or a connected device.
  • yarn ios - To start iOS build for a simulator or a connected device.

Architecture

The driving goal of the architecture of the boilerplate is separation of concerns. Namely:

  • Presentational components are separated from containers (aka "screens").

    Presentational components are small components that are concerned with how things look. Containers usually define whole application screens and are concerned with how things work: they include presentational components and wire everything together.

    If you are interested you can read more about it here.

  • State is managed using global Redux stores.

    When applications grow, sharing state and its changes can become very hard. Questions like "How can I access this data?" or "When did this change?" are common, just like passing data around components just to be able to use it in nested components.

    With Redux, state is shared using global stores, and changes are predictable: actions are applied by reducers to the state. While the pattern can be a bit much for small projects, the clear separation of responsibilities and predictability helps with bigger applications.

    If you are interested you can read more about it here.

  • Application side-effects (API calls, etc.) are separated from UI and state manipulation using Redux Saga.

    Using Redux Saga has two benefits: keeping application side-effects and related business logic out of UI components, as well as executing that logic in an asynchronous way without ending in callback hell.

    Sagas are triggered by Redux actions and can also trigger Redux actions to alter state. By using JavaScript generators (yield), sagas are written in a synchronous-like manner while still executing asynchronously.

Content

The boilerplate contains:

The boilerplate includes an example (displaying fake user data) from UI components to the saga. The example is easy to remove so that it doesn't get in the way.

Directory layout

For more information on each directory, click the link and read the directory's README.

Updates

The boilerplate will follow new React-Native releases as soon as libraries and tools used here are compatible.

Requirements

Node 8 or greater is required. Development for iOS requires a Mac and Xcode 9 or up, and will target iOS 9 and up.

You also need to install the dependencies required by React Native:

Using the boilerplate

To create a new project using the boilerplate:

  • clone this repository
  • remove the previous git history: rm -rf .git/
  • install the npm dependencies by running yarn
  • rename the React Native project to your own project name: yarn run rename -- <YourProjectName> (the default name is Boilerplate)
  • remove the LICENSE file and the "License" section from the README if your project is not open source

Feel free to remove the section "Using the boilerplate" from the README (you will not need it anymore in your project). You are encouraged to keep the rest of the documentation in your project so that it is self-explanatory.

You can now create a new git repository for your project (using git init) and create the first commit.

Running the project

Assuming you have all the requirements installed, you can setup and run the project by running:

  • yarn install to install the dependencies
  • create your configuration file App/Config/index.js from index.dev.js (if you are in dev environment) and fill the missing values
  • run the following steps for your platform

Android

  • only the first time you run the project, you need to generate a debug key with:
    • cd android/app
    • keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000
    • cd ../.. to come back to the root folder
  • yarn start to start the metro bundler, in a dedicated terminal
  • yarn android to run the Android application (remember to start a simulator or connect an Android phone)

iOS

  • cd ios
  • pod install to install pod dependencies
  • cd .. to come back to the root folder
  • yarn start to start the metro bundler, in a dedicated terminal
  • yarn ios to run the iOS application (remember to start a simulator or connect an iPhone phone)

Useful documentation

Deployment

Package dependencies

Troubleshooting

App fails to start after renaming

If your application fails to start after using the yarn run rename command, please take a look at this issue

About

A personal project to get myself well-versed with React Native.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published