redux-actions
  • Read Me
  • Introduction
    • Motivation
    • Tutorial
  • API Reference
    • createAction(s)
    • handleAction(s)
    • combineActions
  • External Resources
  • Changelog
  • Contributors
Powered by GitBook
On this page
  • redux-actions
  • Getting Started
  • Installation
  • Usage
  • Documentation

Read Me

NextIntroduction

Last updated 2 years ago

redux-actions

utilities for Redux

Table of Contents

Getting Started

Installation

$ npm install --save redux-actions

or

$ yarn add redux-actions

The package provides that should be compatible with every modern build tooling.

Usage

import { createActions, handleActions, combineActions } from 'redux-actions';

const defaultState = { counter: 10 };

const { increment, decrement } = createActions({
  INCREMENT: (amount = 1) => ({ amount }),
  DECREMENT: (amount = 1) => ({ amount: -amount })
});

const reducer = handleActions(
  {
    [combineActions(increment, decrement)]: (
      state,
      { payload: { amount } }
    ) => {
      return { ...state, counter: state.counter + amount };
    }
  },
  defaultState
);

export default reducer;

Documentation

See the full API documentation.
Introduction
API
External Resources
Changelog
Contributors
Flux Standard Action
npm
ES modules
Getting Started
Installation
Usage
Documentation
Build Status
codecov
npm
npm