redux-batched-actions
redux-batched-actions copied to clipboard
Batch middleware can cause infinite recursion
original comment: https://github.com/tshelburne/redux-batched-actions/pull/18#issuecomment-364916115
Is there a workaround for this issue?
batchDispatchMiddleware always causes an infinite loop for me. I can't get the example to work.
import {createStore, applyMiddleware} from 'redux'
import {batchActions, enableBatching, batchDispatchMiddleware} from 'redux-batched-actions'
import {createAction} from 'redux-actions'
const doThing = createAction('DO_THING')
const doOther = createAction('DO_OTHER')
function reducer (state, action) {
switch (action.type) {
case 'DO_THING': return 'thing'
case 'DO_OTHER': return 'other'
default: return state
}
}
// Handle bundled actions in reducer
const store = createStore(
enableBatching(reducer),
'',
applyMiddleware(batchDispatchMiddleware)
)
store.dispatch(batchActions([doThing(), doOther()]))
// OR
store.dispatch(batchActions([doThing(), doOther()], 'DO_BOTH'))

Versions [email protected] [email protected] [email protected]
@dadamssg @tshelburne @nikolal See my pull request
Hey all, apologies for the delay, big releases at work prevented me from checking this stuff out. Gonna take a look.
@tshelburne thanks for the lib before anything.
I came to this issue to say that I couldn't make the lib work by applying the middleware, when I did this, all actions were dispatched normally, one by one, triggering the render, plus the BATCHING_REDUCER.BATCH one.
I could put it to work with enableBatching.
My attempt to use the middleware was with redux-saga, applying applyMiddleware(sagaMiddleware, batchDispatchMiddleware).