Files
react/components/file-tree/tree-context.ts
2020-03-25 12:57:34 +08:00

18 lines
413 B
TypeScript

import React from 'react'
export interface TreeConfig {
onFileClick: (path: string) => void
initialExpand: boolean
isImperative: boolean
}
const defaultContext = {
onFileClick: () => {},
initialExpand: false,
isImperative: false,
}
export const TreeContext = React.createContext<TreeConfig>(defaultContext)
export const useTreeContext = (): TreeConfig => React.useContext<TreeConfig>(TreeContext)