Skip to content

Instantly share code, notes, and snippets.

@ianitsky
Last active December 3, 2018 14:34
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 ianitsky/3cae0e73c2cdab640a882afb1b93f334 to your computer and use it in GitHub Desktop.
Save ianitsky/3cae0e73c2cdab640a882afb1b93f334 to your computer and use it in GitHub Desktop.
Javascript

Default float money to real money

value.toLocaleString('pt-br', {minimumFractionDigits: 2})

Mask

Postcode

import MaskedInput from 'react-text-mask';

function TextMaskPostcode(props) {
  const { inputRef, ...other } = props;

  return (
    <MaskedInput
      {...other}
      ref={inputRef}
      mask={[/\d/,/\d/,/\d/,/\d/,/\d/,'-',/\d/,/\d/,/\d/,]}
      placeholderChar={'_'}
    />
  );
}

<TextField
  InputProps={{
    inputComponent: TextMaskPostcode,
  }}
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment