Files
react/components/radio/radio-context.ts
2020-06-20 13:25:12 +08:00

18 lines
418 B
TypeScript

import React from 'react'
export interface RadioConfig {
updateState?: (value: string | number) => void
disabledAll: boolean
value?: string | number
inGroup: boolean
}
const defaultContext = {
disabledAll: false,
inGroup: false,
}
export const RadioContext = React.createContext<RadioConfig>(defaultContext)
export const useRadioContext = (): RadioConfig => React.useContext<RadioConfig>(RadioContext)