mirror of
https://github.com/zhigang1992/react.git
synced 2026-04-24 04:15:54 +08:00
18 lines
400 B
TypeScript
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)
|