mirror of
https://github.com/zhigang1992/react.git
synced 2026-04-26 13:25:46 +08:00
23 lines
724 B
TypeScript
23 lines
724 B
TypeScript
import React from 'react'
|
|
import { ToastWithID } from '../toast/toast-container'
|
|
|
|
export type UpdateToastsFunction<T> = (fn: (toasts: Array<T>) => Array<T>) => any
|
|
|
|
export interface ZeitUiContextParams {
|
|
toasts: Array<ToastWithID>
|
|
toastHovering: boolean
|
|
updateToasts: UpdateToastsFunction<ToastWithID>
|
|
updateToastHoverStatus: Function
|
|
}
|
|
|
|
const defaultParams: ZeitUiContextParams = {
|
|
toasts: [],
|
|
toastHovering: false,
|
|
updateToasts: t => t,
|
|
updateToastHoverStatus: () => {}
|
|
}
|
|
|
|
export const ZEITUIContent:React.Context<ZeitUiContextParams> = React.createContext<ZeitUiContextParams>(defaultParams)
|
|
|
|
export const useZEITUIContext = (): ZeitUiContextParams => React.useContext<ZeitUiContextParams>(ZEITUIContent)
|