Files
react/components/radio/radio-context.ts
2020-03-19 23:20:15 +08:00

19 lines
424 B
TypeScript

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