Code Monkey home page Code Monkey logo

react-currency-formatter's Introduction

💵 react currency formatter

npm npm David Travis license

💻 DEMO!

Usage

Simple

import Currency from 'react-currency-formatter';

<Currency
  quantity={45685}
  currency="EUR"
/>

Complex

import Currency from 'react-currency-formatter';

<Currency
  quantity={45685}          // Required
  currency="USD"            // Optional (USD by default)
  locale="en_EN"            // Optional
  pattern="##,### !"        // Optional
  decimal=","               // Optional
  group="."                 // Optional
/>

TypeScript

import * as React from 'react'
import * as CurrencyFormatter from 'react-currency-formatter'

type Props = {
	price: number,
	currency: string,
}

const ProductionPrice: React.SFC<Props> = (props: Props) => (
	<CurrencyFormatter quantity={props.price} currency={props.currency} />
)

export default ProductionPrice

Support

Please open an issue for support.

Contributing

Please contribute using Github Flow. Create a branch, add commits, and open a pull request.

react-currency-formatter's People

Contributors

xdae avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-currency-formatter's Issues

Not working for arabic locale

I used the following code:

<Currency
                          quantity={45685} // Required
                          currency="AED" // Optional (USD by default)
                          locale="ar_AE" // Optional
                          
                        />

THB Currency

Hi guys,
When i put THB as the currency i got only "B"
for example :<Currency quantity={"100"} currency="THB"/>
will print :100B

No group separator

Hi,
Thanks for this useful component,

I would like to format amounts with no group separator, for instance: 258369.78 €

Is it possible with the available props ?
For now when I specify 'group=""', the last group digit before the decimal separator is truncated.

Thanks !

Euro support

Is there a way for me to get the euro symbol infront of the amount? Couldn't fix it using pattern prop: '! ##,###'

export the formater

export a function that return the formatted string instead of a React element.

Remove decimals

Hi,

Is there a way to remove the decimal places of a value while still maintaining the pattern for the various currencies (ie. EUR symbol after value)

Thanks

Error in IE11 when used with react-hot-loader

Gettting the following error in IE11 when react-currency-formatter is used with react-hot-loader:

Object.getPrototypeOf: 'this' is not an Object.

It appears that, in IE11, if a non object value is passed into Object.getPrototypeOf('string') it throws an error.

This is used in react-hot-loader here:

function isReactClassInstance(Component) {
  return Component && isReactClass({ prototype: Object.getPrototypeOf(Component) });
}

And as the <Currency /> component seems to return a plain string $1.00, and not markup <span>$1.00</span> it falls over.

create-react-app/webpack failed to minify as module needs to be submitted in ES5 on npm

Trying to run a production build on create-react-app and get the following error:

yarn run v1.3.2
$ react-scripts build
Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file:

 	./node_modules/react-currency-formatter/dist/react-currency-formatter.umd.js:2966

Read more here: http://bit.ly/2tRViJ9

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

create-react-app requires that packages be compiled to ES5 before being submitted to npm

The linked documentation at http://bit.ly/2tRViJ9 says to

Open an issue on the dependency's issue tracker and ask that the package be published pre-compiled.

Non-existing locale throws: Cannot read property 'h' of undefined

It seems like the package is currently broken:

TypeError: Cannot read property 'h' of undefined
getFormatter @ react-currency-formatter/dist/react-currency-formatter.umd.js:2992:29
format @ react-currency-formatter/dist/react-currency-formatter.umd.js:3161:29
ReactCurrencyFormatter @ /react-currency-formatter/dist/react-currency-formatter.umd.js:3175:10

See this CodeSandbox: https://codesandbox.io/s/x675zp55w

Seems to be this line of code, but I cannot make sense of it:

if (!isUndefined(locale.h)) locale = locales[locale.h]; // Locale inheritance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.