mirror of
https://github.com/zhigang1992/react.git
synced 2026-02-06 09:09:09 +08:00
18 lines
413 B
TypeScript
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)
|