1 import type { ReactNode } from 'react';
2 import { useMemo, useState } from 'react';
4 import { ModalPositionsProvider } from '../../components/modalTwo/modalPositions';
5 import ModalsChildrenContext from './childrenContext';
6 import type { Modal } from './interface';
7 import createManager from './manager';
8 import ModalsContext from './modalsContext';
14 const ModalsProvider = ({ children }: Props) => {
15 const [modals, setModals] = useState<Modal[]>([]);
17 const manager = useMemo(() => {
18 return { ...createManager(modals, setModals), modals };
19 }, [modals, setModals]);
22 <ModalPositionsProvider>
23 <ModalsContext.Provider value={manager}>
24 <ModalsChildrenContext.Provider value={modals}>{children}</ModalsChildrenContext.Provider>
25 </ModalsContext.Provider>
26 </ModalPositionsProvider>
30 export default ModalsProvider;