1
0
Fork 1
mirror of https://github.com/thatmattlove/hyperglass.git synced 2026-02-02 07:19:30 +00:00
thatmattlove-hyperglass/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);
}