@sgnl-pro/react-tree
Version:
A tree view component for React
18 lines (15 loc) • 524 B
text/typescript
import { createContext } from 'react';
import { ITreeItem } from '../types';
import { noop } from '../utils';
import { getInitialTreeState, ITreeState } from './treeReducer';
export const treeStateContext = createContext<ITreeState>(
getInitialTreeState()
);
export interface ITreeActions {
toggleExpanded: (item: ITreeItem, isExpanded: boolean) => void;
toggleSelected: (item: ITreeItem) => void;
}
export const treeActionsContext = createContext<ITreeActions>({
toggleExpanded: noop,
toggleSelected: noop,
});