import React from 'react'; import { useSpring, animated } from 'react-spring'; import styles from './MetricCard.module.css'; function defaultFormat(n) { return Number(n).toFixed(0); } const MetricCard = ({ value = 0, label, format = defaultFormat }) => { const props = useSpring({ x: value, from: { x: 0 } }); return (
{props.x.interpolate(x => format(x))}
{label}
); }; export default MetricCard;