Skip to content

Latest commit

 

History

History
40 lines (27 loc) · 789 Bytes

parseNumber.md

File metadata and controls

40 lines (27 loc) · 789 Bytes

parseNumber

Parses a number based on the locale and options.

parseNumber(value, options?)

Arguments

  • value - string - Number string to be parsed
  • options? - object - Parsing options

Example

import { useGlobalize } from 'react-native-globalize';

const ExampleComponent = () => {
  const { parseNumber } = useGlobalize();

  parseNumber('100,000.00');
  // Number(100000)
};

Options

style

Type Required Default Description
string No decimal Change parsing style. Possible values: decimal, percent.
parseNumber('0.45', { style: 'decimal' });
// Number(0.45)
formatNumber('45%', { style: 'percent' });
// Number(0.45)