mirror of
https://github.com/zhigang1992/react.git
synced 2026-02-10 09:03:57 +08:00
16 lines
337 B
TypeScript
16 lines
337 B
TypeScript
import React from 'react'
|
|
|
|
export interface ModalConfig {
|
|
close: () => void
|
|
open: () => void
|
|
}
|
|
|
|
const defaultContext = {
|
|
close: () => {},
|
|
open: () => {},
|
|
}
|
|
|
|
export const ModalContext = React.createContext<ModalConfig>(defaultContext)
|
|
|
|
export const useModalContext = (): ModalConfig => React.useContext<ModalConfig>(ModalContext)
|