lookingglass/hyperglass/ui/hooks/useStrf.ts
2020-12-31 23:09:54 -07:00

11 lines
319 B
TypeScript

import { useMemo } from 'react';
import format from 'string-format';
import type { UseStrfArgs } from './types';
/**
* Format a string with variables, like Python's string.format()
*/
export function useStrf(str: string, fmt: UseStrfArgs, ...deps: any[]): string {
return useMemo(() => format(str, fmt), deps);
}