Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tienifr committed Jan 21, 2024
1 parent ddffc25 commit 5b440b7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/components/MenuItemGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {createContext} from 'react';
import React, {createContext, useMemo} from 'react';
import useSingleExecution from '@hooks/useSingleExecution';
import type {Action} from '@hooks/useSingleExecution';
import useWaitForNavigation from '@hooks/useWaitForNavigation';
Expand All @@ -11,20 +11,25 @@ type MenuItemGroupContextProps = {

const MenuItemGroupContext = createContext<MenuItemGroupContextProps | undefined>(undefined);

interface MenuItemGroupProps {
type MenuItemGroupProps = {
/* Actual content wrapped by this component */
children: React.ReactNode;

/** Whether or not to use the single execution hook */
shouldUseSingleExecution: boolean;
}
};

const MenuItemGroup: React.FC<MenuItemGroupProps> = ({children}) => {
function MenuItemGroup({children, shouldUseSingleExecution = true}: MenuItemGroupProps) {
const {isExecuting, singleExecution} = useSingleExecution();
const waitForNavigate = useWaitForNavigation();

return <MenuItemGroupContext.Provider value={{isExecuting, singleExecution, waitForNavigate}}>{children}</MenuItemGroupContext.Provider>;
};
const value = useMemo(
() => (shouldUseSingleExecution ? {isExecuting, singleExecution, waitForNavigate} : undefined),
[shouldUseSingleExecution, isExecuting, singleExecution, waitForNavigate],
);

return <MenuItemGroupContext.Provider value={value}>{children}</MenuItemGroupContext.Provider>;
}

export {MenuItemGroupContext};
export default MenuItemGroup;

0 comments on commit 5b440b7

Please sign in to comment.