mirror of
https://github.com/zhigang1992/react.git
synced 2026-03-27 22:54:38 +08:00
19 lines
424 B
TypeScript
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)
|