Skip to content

Commit

Permalink
Memoizing composed reducer (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinMarioGerard authored Jan 30, 2020
1 parent 060d576 commit debf83a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/Shuttle/hooks/useShuttleState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,15 @@ export function useShuttleState(
},
reducers: { [key: string]: Function } = {}
) {
const composedReducer = React.useCallback(
composeReducers({ move, moveAll, selectItem, lazyLoad, ...reducers }),
[]
);

// TODO: fix the type errors
// @ts-ignore
const [shuttleState, setShuttleState] = React.useReducer(
composeReducers({ move, moveAll, selectItem, lazyLoad, ...reducers }),
composedReducer,
{
...initialState,
// @ts-ignore
Expand Down

0 comments on commit debf83a

Please sign in to comment.