1
0
Fork 1
mirror of https://github.com/thatmattlove/hyperglass.git synced 2026-01-29 13:29:20 +00:00
thatmattlove-hyperglass/hyperglass/ui/hooks/useStrf.ts
2021-01-03 23:51:09 -07:00

11 lines
323 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: unknown[]): string {
return useMemo(() => format(str, fmt), deps);
}