Files
react/components/radio/radio-context.ts
2020-05-28 11:03:22 +08:00

18 lines
400 B
TypeScript

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