Fix Infinite loop on invite route (#2866)

This commit is contained in:
Charles Bochet
2023-12-07 19:26:07 +01:00
committed by GitHub
parent 5efc2f00b9
commit 6c83953633
5 changed files with 93 additions and 72 deletions

View File

@ -1,3 +1,4 @@
import { useCallback } from 'react';
import { useRecoilCallback, useSetRecoilState } from 'recoil';
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
@ -38,9 +39,12 @@ export const useCommandMenu = () => {
}
});
const addToCommandMenu = (addCommand: Command[]) => {
setCommands((prev) => [...prev, ...addCommand]);
};
const addToCommandMenu = useCallback(
(addCommand: Command[]) => {
setCommands((prev) => [...prev, ...addCommand]);
},
[setCommands],
);
const setToIntitialCommandMenu = () => {
setCommands(commandMenuCommands);