redux-utilities/redux-actions

Flux Standard Action utilities for Redux.

JavaScript

6,448

217 commits

updated Jul 21, 2024

See the code

README

redux-actions

Build Status codecov npm npm

Flux Standard Action utilities for Redux

Table of Contents

Getting Started

Installation

$ npm install --save redux-actions

or

$ yarn add redux-actions

The npm package provides ES modules 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;

See the full API documentation.

Documentation

redux-utilities/redux-actions

Flux Standard Action utilities for Redux.

JavaScript

6,448

217 commits

updated Jul 21, 2024

See the code

README

redux-actions

Build Status codecov npm npm

Flux Standard Action utilities for Redux

Table of Contents

Getting Started

Installation

$ npm install --save redux-actions

or

$ yarn add redux-actions

The npm package provides ES modules 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;

See the full API documentation.

Documentation

Project health

Overall

3.5/10

Maintained

0/10

Code review

4/10
OpenSSF Scorecard

Latest release

3.0.3 · Jul 21, 2024

Releases this year

0

Significant stargazers

(top 24 of 32)

Florian Verdonck

148 followers · starred May 2016

Juriy Zaytsev

3,401 followers · starred Jun 2018

Erez Rokah

206 followers · starred Jul 2018

TylerBrock

166 followers · starred Sep 2016