Giter VIP home page Giter VIP logo

nikhils4 / react-currency-conv Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 2.0 332 KB

React component as an npm package for currency conversion. Supports fetching the latest and historical currency exchange rate based on the input date along with specific precision.

Home Page: https://www.npmjs.com/package/react-currency-conv

License: MIT License

JavaScript 100.00%
currency converter react npm package historical-data currency-conversion exchange-rate precision

react-currency-conv's Introduction

react-currency-conv

React component for currency conversion. Supports fetching latest and historical currency exchange rate based on the input date alongwith specific precision.

Changes

v1.1.0:

  • Update documentation
  • Minor bug fixes

Installation

npm install react-currency-conv --save

Integration

You can get the converted value as the output of the react component and style it according to your preference.

  • from: Initial currency
  • to: Target currency
  • value: The amount that you want to get converted
import React from 'react';
import CurrencyConverter from 'react-currency-conv';

export default class App extends React.Component {
  render() {
    return (
      <div className="App">
        <CurrencyConverter from={'USD'} to={'CAD'} value={29}/>
      </div>
    );
  }
}

Precision

Specify a specific precision:

    // 2234.67 (default)
    <CurrencyConverter from={'USD'} to={'CAD'} value={29} precision={2}/>
    // 78.2482
    <CurrencyConverter from={'USD'} to={'CAD'} value={29} precision={4}/>

Date

To get the exchange rate value form :-

	// NOTE: The date should be in `YYYY-MM-DD` format
    <CurrencyConverter from={'USD'} to={'CAD'} value={29} date={'2010-12-22'}/>

All other attributes are applied normally to the element. For example, you can integrate bootstrap styling as:

    <CurrencyConverter from={'USD'} to={'CAD'} value={29} className="form-control"/>

Options

Option Default Value Description
date null Date you want to fetch exchange rate of (YYYY-MM-DD)
precision 2 Number of digits after the decimal separator

Supported currencies

Code
INR
IDR
ILS
MXN
USD
ZAR
NZD
NOK
CNY
BGN
TRY
PLN
SGD
CHF
THB
JPY
HRK
RUB
BRL
CAD
HKD
ISK
PHP
DKK
HUF
CZK
RON
SEK
AUD
EUR
MYR
KRW
GBP

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.