react-redux-batch
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

react-redux-batch

Simplified version of batch-helper (https://react-redux.js.org/api/batch#batch) that's provided by react-redux package.

npm install --save react-redux-batch (make sure you've installed react-redux 7.0.1+)

Usage

import {batch} from 'react-redux-batch'

function myThunk() {
  return (dispatch, getState) => {
  
    // Causes 3 re-renders (1 re-render per dispatch)
    dispatch(increment())
    dispatch(increment())
    dispatch(increment())
    
    // Causes 1 re-render
    batch(dispatch, [increment(), increment(), increment()])
    
    // batch provided by react-redux. Also causes 1 re-render
    // batch(() => { dispatch(increment()); dispatch(increment()); dispatch(increment()) })
  }
}

/react-redux-batch/

    Package Sidebar

    Install

    npm i react-redux-batch

    Weekly Downloads

    3

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    2.8 kB

    Total Files

    5

    Last publish

    Collaborators

    • hypotenuse-packs