diff --git a/src/reducers/__tests__/arrayReducer.test.js b/src/reducers/__tests__/arrayReducer.test.js index f8f9ed2..849f8c7 100644 --- a/src/reducers/__tests__/arrayReducer.test.js +++ b/src/reducers/__tests__/arrayReducer.test.js @@ -40,7 +40,7 @@ describe('arrayReducer', () => { describe('removeAtIndex', () => { const { removeAtIndex } = DEFAULT_ARRAY_BEHAVIORS; it('should remove at index correctly', () => { - expect(removeAtIndex.reducer([1,2,3], undefined, undefined, 0)).toEqual([2,3]); + expect(removeAtIndex.reducer([1,2,3], 0)).toEqual([2,3]); }); it('should return state if no index provided', () => { expect(removeAtIndex.reducer([1,2,3])).toEqual([1,2,3]); diff --git a/src/reducers/arrayReducer.js b/src/reducers/arrayReducer.js index 45fe122..9a68392 100644 --- a/src/reducers/arrayReducer.js +++ b/src/reducers/arrayReducer.js @@ -45,7 +45,7 @@ import { updateAtIndex, removeAtIndex } from '../utils/arrayUtils'; import { PROP_TYPES } from '../structure'; -function checkIndex(index: ?number, payload: any, behaviorName: string): boolean { +function checkIndex(index: ?number, payload: any = '', behaviorName: string = ''): boolean { if (!isNumber(index) || index === -1) { console.warn(`Index not passed to ${behaviorName} for payload ${payload}.`); return false; @@ -81,8 +81,8 @@ export const DEFAULT_ARRAY_BEHAVIORS: ArrayReducerBehaviorsConfig = { validate: false, }, removeAtIndex: { - reducer(state, payload, initialState, index) { - if (!checkIndex(index, payload, 'removeAtIndex')) return state; + reducer(state, index) { + if (!checkIndex(index, '', 'removeAtIndex')) return state; return removeAtIndex(state, index); }, validate: false,