All files / src/DropdownMenu DropdownMenuState.tsx

25% Statements 1/4
100% Branches 0/0
50% Functions 1/2
25% Lines 1/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22                      85x                    
import * as React from 'react';
import {
  useMenuState as useReakitMenuState,
  MenuStateReturn as ReakitMenuStateReturn,
  MenuInitialState as ReakitMenuInitialState
} from 'reakit';
 
export type DropdownMenuStateReturn = ReakitMenuStateReturn;
export type DropdownMenuInitialState = ReakitMenuInitialState;
 
export function useDropdownMenuState(initialState?: DropdownMenuInitialState) {
  return useReakitMenuState({ gutter: 8, ...initialState });
}
 
export function DropdownMenuState(
  props?: { children?: (state: DropdownMenuStateReturn) => any } & DropdownMenuInitialState
) {
  const { children, ...restProps } = props;
  const state = useDropdownMenuState(restProps);
  return props.children(state);
}