Skip to content

Instantly share code, notes, and snippets.

@AlexGeb
Last active January 4, 2019 09:43
Show Gist options
  • Save AlexGeb/7d5849d3d38b60a8f874cc59b92af082 to your computer and use it in GitHub Desktop.
Save AlexGeb/7d5849d3d38b60a8f874cc59b92af082 to your computer and use it in GitHub Desktop.
NumberFormat for displaying percentage with '%' suffix
function PercentageNumber(props) {
const { value, inputRef, onChange, fieldName, ...other } = props;
return (
<NumberFormat
{...other}
value={value * 100}
decimalScale={2}
getInputRef={inputRef}
onValueChange={values => {
onChange(values.value / 100);
}}
suffix="%"
/>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment