1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00
Files
checktheroads-hyperglass/hyperglass/ui/hooks/useStrf.ts

12 lines
323 B
TypeScript
Raw Normal View History

import { useMemo } from 'react';
import format from 'string-format';
2020-12-31 23:09:54 -07:00
import type { UseStrfArgs } from './types';
2020-12-31 23:09:54 -07:00
/**
* Format a string with variables, like Python's string.format()
*/
2021-01-03 23:51:09 -07:00
export function useStrf(str: string, fmt: UseStrfArgs, ...deps: unknown[]): string {
return useMemo(() => format(str, fmt), deps);
}