UNPKG

react-beautiful-dnd

Version:

Beautiful, accessible drag and drop for lists with React.js

22 lines (19 loc) 615 B
// @flow import invariant from 'tiny-invariant'; import { completeDrop } from '../action-creators'; import type { State } from '../../types'; import type { MiddlewareStore, Action, Dispatch } from '../store-types'; export default (store: MiddlewareStore) => (next: Dispatch) => ( action: Action, ): any => { if (action.type !== 'DROP_ANIMATION_FINISHED') { next(action); return; } const state: State = store.getState(); invariant( state.phase === 'DROP_ANIMATING', 'Cannot finish a drop animating when no drop is occurring', ); store.dispatch(completeDrop(state.pending.result)); };