import { SetStateAction } from 'react'; export type Binding = { value: T; setValue: React.Dispatch>; }; export type BooleanBinding = Binding & { toggle: () => void }; export function getValueOrBinding(incoming: T | Binding): T { const value = incoming && typeof incoming === 'object' && 'value' in incoming ? incoming.value : incoming; return value as T; }