Skip to content

Instantly share code, notes, and snippets.

@marcelmokos
Last active January 16, 2019 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcelmokos/b987a37e46e3fc6796e3ecda8b2aff94 to your computer and use it in GitHub Desktop.
Save marcelmokos/b987a37e46e3fc6796e3ecda8b2aff94 to your computer and use it in GitHub Desktop.
Openslava
const FormattedNumber = ({ value, roundingFn = val => val }) => roundingFn(value);
//js
console.log(
FormattedNumber({value: 5.6}) /* 5.6 */
);
//jsx
<FormattedNumber value={5.6} /> /* 5.6 */
<FormattedNumber value={5.6} roundingFn={Math.floor} /> /* 5 */
<FormattedNumber value={5.6} roundingFn={Math.ceil} /> /* 6 */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment