| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 1x 2x 2x | import _ from 'lodash'; export function onSelect(state = {}, index) { return { ...state, selectedIndices: [index], } } export function onToggle(state = {}, index) { const expandedIndices = state.expandedIndices || []; return { ...state, expandedIndices: _.xor(expandedIndices, [index]), } } |