Registry / payment / react-currency-formatter-v2

react-currency-formatter-v2

JSON →
library1.1.3jsnpmunverified

A lightweight React component for formatting currency values using Intl.NumberFormat under the hood. Current stable version is 1.1.3, with low release cadence (last update 5+ years ago). Supports custom locale, currency code, pattern, decimal and group separators. Key differentiator: simple component-based API vs. utility functions. Requires React 16.x. Note: this is the v2 fork of react-currency-formatter; the original package is deprecated.

npm install react-currency-formatter-v2
INSTALL
IMPORT
SIG · REACT-CURRENCY-FOR
R
react-currency-formatter-v2
paymentjavascriptv1.1.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Currency
import Currency from 'react-currency-formatter'
import { Currency } from 'react-currency-formatter'
Default export, not named. Common mistake: destructuring with curly braces.
default (TS import with * as)
import * as CurrencyFormatter from 'react-currency-formatter'
import CurrencyFormatter from 'react-currency-formatter'
TypeScript users often use namespace import to avoid issues with default export.
Currency (require)
const Currency = require('react-currency-formatter').default
const Currency = require('react-currency-formatter')
CJS require gives an object with .default property; calling directly fails.

Shows basic usage of the Currency component with required quantity and optional formatting props.

import Currency from 'react-currency-formatter'; function App() { return ( <Currency quantity={1234.56} currency="USD" locale="en-US" decimal="." group="," /> ); } export default App;
Debug
Known issues
breakingComponent returns a string, not a React element. Do not use as a child of another component expecting a React node.
fix
Wrap in a <span> or use as a text child.
affects: >=1.0.0
deprecatedOriginal package react-currency-formatter is deprecated in favor of this v2 fork due to lack of maintenance.
fix
Upgrade to react-currency-formatter-v2 (this package).
affects: <1.0.0
gotchaThe 'locale' prop expects a BCP 47 language tag (e.g., 'en-US'), not an underscore format like 'en_EN' as shown in the old README.
fix
Use proper locale strings per Intl.NumberFormat specification.
affects: >=1.0.0
gotchaReact 16.x peer dependency. Using with React 17+ may cause unknown issues, though often works.
fix
Consider alternative with wider React support.
affects: <=1.1.3
gotchaThe component uses Intl.NumberFormat which may not be available in older browsers (e.g., IE 11 without polyfill).
fix
Include a polyfill for Intl.NumberFormat or use a different library for legacy support.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Currency is not a function
Using require without .default, or using named import incorrectly.
fix
Use: const Currency = require('react-currency-formatter').default;
Warning: Failed prop type: Invalid prop 'currency' of type 'array' supplied to 'Currency', expected 'string'.
Passing an array or object as currency prop instead of a string.
fix
Ensure currency is a string like 'USD'.
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
Using the component without default import (e.g., import { Currency }...).
fix
Use default import: import Currency from 'react-currency-formatter';
Upgrade
Version history
1.1.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
react-currency-formatter-v2 — npm install react-currency-formatter-v2 · libregistry