Git Product home page Git Product logo

react-redux-typescript-starter's Introduction

react-redux-typescript-starter

Starter project for React + Redux + Typescript

Installation

From project directory.

$ npm install

Useful commands:

Tests:

Run Unit tests.

$ npm run test

Run Unit tests in watch mode

$ npm run test:w

Run Unit test coverage:

$ npm run coverage

Debug Server:

Launch a live server that is updated with code changes.

$ npm run start

Node version issues

  • None

Terms

Reducer

A reducer updates the Application State according to an action.

Action

A set of data to be applied to the Application State. It has two parts:

  1. type -- the action identifier
  2. payload -- the data to be used.

Application State

This is the data model used to drive the application. All state is in Application State. We use Redux to manage the Application State. Application State is only modified through the reducers using redux.store.dispatch()

EventFunction

EventsFunction when called create action or actions and dispatches them. It is the interface between the component and the Application State. EventFunctions are used to make things happen. Provides the separation of concern between components and the Application State. EventFunctions are injected into components through their properties.

AsyncAction

AsyncActions are used to perform any asynchronous requests, for example, calling the a server API.

Writing Components

  1. Define the Application State to be used by the component
  2. Create the Stateless Render function or ReactComponent
    • define the properties
    • write unit test for component (use enzyme).
  3. Create Action/Reducer pairs
    1. Define the Actions that can be applied to the Application State
    2. Define the reducers that handle the Actions
      • create a default reducer
    3. write unit tests for both Actions and Reducers
  4. Add User Interaction
    • Define the Actions that the component that it might trigger
    • write the event functions

Event cycle

  1. Component triggers an event through onActionFunction that is injected into the component.
  2. The onActionFunction calls store.dispatch(Action)
  3. The reducers listen for the Action and change the Application State
  4. Redux tells react to render the new Application State
  5. Start over at 1.

Async Action

Async Actions are actions that used for making async calls to things like the API. The Api calls will result in a store.dispatch(resultingAction).

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.