Files
react/lib/config-context.ts
2020-04-04 13:04:30 +08:00

20 lines
489 B
TypeScript

import React from 'react'
export interface Configs {
onChange?: Function
isChinese?: boolean
updateChineseState: Function
sidebarScrollHeight: number
updateSidebarScrollHeight: Function
}
export const defaultConfigs: Configs = {
sidebarScrollHeight: 0,
updateSidebarScrollHeight: () => {},
updateChineseState: () => {},
}
export const ConfigContext = React.createContext<Configs>(defaultConfigs)
export const useConfigs = (): Configs => React.useContext(ConfigContext)