Starter project for React + Redux + Typescript
From project directory.
$ npm install
Run Unit tests.
$ npm run test
Run Unit tests in watch mode
$ npm run test:w
Run Unit test coverage:
$ npm run coverage
Launch a live server that is updated with code changes.
$ npm run start
- None
A reducer updates the Application State according to an action.
A set of data to be applied to the Application State. It has two parts:
- type -- the action identifier
- payload -- the data to be used.
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()
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.
AsyncActions are used to perform any asynchronous requests, for example, calling the a server API.
- Define the Application State to be used by the component
- Create the Stateless Render function or ReactComponent
- define the properties
- write unit test for component (use enzyme).
- Create Action/Reducer pairs
- Define the Actions that can be applied to the Application State
- Define the reducers that handle the Actions
- create a default reducer
- write unit tests for both Actions and Reducers
- Add User Interaction
- Define the Actions that the component that it might trigger
- write the event functions
- Component triggers an event through onActionFunction that is injected into the component.
- The onActionFunction calls store.dispatch(Action)
- The reducers listen for the Action and change the Application State
- Redux tells react to render the new Application State
- Start over at 1.
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).