import React from "react"; export function notEmpty( value: TValue | null | undefined, ): value is TValue { return value !== null && value !== undefined; } // Thank you https://stackoverflow.com/a/49725198 export type RequireOnlyOne = Pick< T, Exclude > & { [K in Keys]-?: Required> & Partial, undefined>>; }[Keys]; export const isBrowser = (): boolean => typeof window !== "undefined"; export const useFocus = (): [React.RefObject, () => void] => { const htmlElRef = React.useRef(null); const setFocus = (): void => { htmlElRef.current && htmlElRef.current.focus(); }; return [htmlElRef, setFocus]; };