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