14 lines
415 B
JavaScript
14 lines
415 B
JavaScript
import React from 'react';
|
|
import { FormattedNumber } from 'react-intl';
|
|
|
|
const isNumber = number => typeof number === 'number' && number !== NaN;
|
|
|
|
export const shortNumberFormat = number => {
|
|
if (!isNumber(number)) return '•';
|
|
|
|
if (number < 1000) {
|
|
return <FormattedNumber value={number} />;
|
|
} else {
|
|
return <span><FormattedNumber value={number / 1000} maximumFractionDigits={1} />K</span>;
|
|
}
|
|
};
|