mirror of
https://github.com/zhigang1992/react.git
synced 2026-01-25 22:26:32 +08:00
17 lines
389 B
TypeScript
17 lines
389 B
TypeScript
import React from 'react'
|
|
|
|
export interface TreeConfig {
|
|
onFileClick?: (path: string) => void
|
|
initialExpand: boolean
|
|
isImperative: boolean
|
|
}
|
|
|
|
const defaultContext = {
|
|
initialExpand: false,
|
|
isImperative: false,
|
|
}
|
|
|
|
export const TreeContext = React.createContext<TreeConfig>(defaultContext)
|
|
|
|
export const useTreeContext = (): TreeConfig => React.useContext<TreeConfig>(TreeContext)
|