mirror of
https://github.com/zhigang1992/react.git
synced 2026-01-27 08:58:46 +08:00
19 lines
448 B
TypeScript
19 lines
448 B
TypeScript
import React from 'react'
|
|
|
|
export interface CheckboxConfig {
|
|
updateState?: (value: string, checked: boolean) => void
|
|
disabledAll: boolean
|
|
values: string[]
|
|
inGroup: boolean
|
|
}
|
|
|
|
const defaultContext = {
|
|
disabledAll: false,
|
|
inGroup: false,
|
|
values: [],
|
|
}
|
|
|
|
export const CheckboxContext = React.createContext<CheckboxConfig>(defaultContext)
|
|
|
|
export const useCheckbox = (): CheckboxConfig => React.useContext<CheckboxConfig>(CheckboxContext)
|