React library that help to convert your web app currency to its user currency based on ther location
OTHER License
Currencynet is a javascript light library that helps to convert currency between different html tags
npm i currencynet
or
yarn add currencynet
Create a new currencyNet Object
import { CurrencyNet } from 'currencynet'
Now add your the CurrencyNet
jsx element
<CurrencyNet buildCurrency="USD" value={10} isfloat={false} shortenCurrency={true} />
buildCurrency
- This can be replaced by any of ISO 4217 CODE based on the currency used in that element
value
- This is the value of the element in your build currency
isfloat
- (optional) - This is an optional parameter that determine if the currency should be returned as a float or not , default
is true
shortenCurrency
- (optional) - This is an optional param for formatting currencies in shorten form e.g $1200
becomes $1.2k
As seen we will always have to redeclare the buildCurrency
when using it in a component which can be very exhausting , so for best pratice you can create a default component to be used through out your application
import React from 'react'
import {CurrencyNet} from 'currencynet'
//Using props
const MyDollarCurrency = (props) => {
return (
<CurrencyNet buildCurrency="USD" value={props.value} />
)
}
// Using Children
const MyEuroCurrency = ({children}) => {
return (
<CurrencyNet buildCurrency="EUR" value={Number(children)} />
)
}
export default const App = () => {
return (
<div class="App">
<MyDollarCurrency value={10} />
<MyEuroCurrency>
10
</MyEuroCurrency>
</div>
)
}
<CurrencyNet buildCurrency="USD" value={10} isfloat={false} shortenCurrency={true}/>
coming soon
COUNTRY | ISO 4217 CODE | CLASSNAME |
---|---|---|
US Dollar | USD | currencynet-init-usd |
Indian Rupee | INR | currencynet-init-inr |
Euro | EUR | currencynet-init-eur |
Chinese Yuan | CYN | currencynet-init-cyn |
Nigerian Naira | NGN | currencynet-init-ngn |
more are avaliable at our documentation