1.2.3 • Published 3 years ago

react-currency-hooks v1.2.3

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

react-currency-hooks

NPM version NPM downloads

About

Currency converter React hook

How to Install

First, install the library in your project by npm:

$ npm install react-currency-hooks

Or Yarn:

$ yarn add react-currency-hooks

Getting Started

• Import hook in React application file:

import { useCurrency } from 'react-currency-hooks';

Params

NameTypeDefaultDescription
amountnumberAmount of money to convert
options{}Convertion options

Options

NameTypeDefaultDescription
fromstringCurrency to be converted
tostringThe currency to which it is converted
basestringBase currency
rates{}{}Currency rates

Returned Values

TypeDescription
numberConverted value

Example

import React from 'react';
import { useCurrency } from 'react-viewport-hooks';

const App = () => {
  const rates = {
    USD: 1.119132,
    CHF: 1.083733,
    EUR: 1.00
  };
  
  const currency = useCurrency(200, {
    from: 'USD',
    to: 'CHF',
    base: 'EUR',
    rates
  });
  
  return (
    <p>USD to CHF: {currency}</p>
  );
};

export default App;

License

This project is licensed under the MIT License © 2020-present Jakub Biesiada

1.2.4-beta.1

3 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.0.0

4 years ago

1.0.0-beta.1

4 years ago

1.0.0-beta.0

4 years ago