Skip to content

Commit

Permalink
feat: added media context
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushiee committed Sep 8, 2021
1 parent 0552f28 commit f383a43
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions context/ModalContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, { createContext, useState } from 'react';
import { Media } from '../types';

interface Modal {
data: Media;
setModalData: (item: Media) => void;
isModal: boolean;
setIsModal: (isModal: boolean) => void;
}

interface ModalProviderProps {
children: React.ReactNode
}

export const ModalContext = createContext<Modal>({} as Modal);

export function ModalProvider({ children }: ModalProviderProps) {
const [data, setModalData] = useState<Media>({} as Media);
const [isModal, setIsModal] = useState<boolean>(false);

return <ModalContext.Provider value={{ data, setModalData, isModal, setIsModal }}>{children}</ModalContext.Provider>;
}

0 comments on commit f383a43

Please sign in to comment.