Skip to content

Commit debf83a

Browse files
Memoizing composed reducer (#79)
1 parent 060d576 commit debf83a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/components/Shuttle/hooks/useShuttleState.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,15 @@ export function useShuttleState(
8484
},
8585
reducers: { [key: string]: Function } = {}
8686
) {
87+
const composedReducer = React.useCallback(
88+
composeReducers({ move, moveAll, selectItem, lazyLoad, ...reducers }),
89+
[]
90+
);
91+
8792
// TODO: fix the type errors
8893
// @ts-ignore
8994
const [shuttleState, setShuttleState] = React.useReducer(
90-
composeReducers({ move, moveAll, selectItem, lazyLoad, ...reducers }),
95+
composedReducer,
9196
{
9297
...initialState,
9398
// @ts-ignore

0 commit comments

Comments
 (0)