1.2.3 • Published 5 years ago
react-currency-hooks v1.2.3
react-currency-hooks
About
Currency converter React hook
How to Install
First, install the library in your project by npm:
$ npm install react-currency-hooksOr Yarn:
$ yarn add react-currency-hooksGetting Started
• Import hook in React application file:
import { useCurrency } from 'react-currency-hooks';Params
| Name | Type | Default | Description |
|---|---|---|---|
| amount | number | | Amount of money to convert |
| options | {} | | Convertion options |
Options
| Name | Type | Default | Description |
|---|---|---|---|
| from | string | | Currency to be converted |
| to | string | | The currency to which it is converted |
| base | string | | Base currency |
| rates | {} | {} | Currency rates |
Returned Values
| Type | Description |
|---|---|
| number | Converted 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
5 years ago
1.2.3
6 years ago
1.2.2
6 years ago
1.2.1
6 years ago
1.2.0
6 years ago
1.1.1
6 years ago
1.1.0
6 years ago
1.1.3
6 years ago
1.1.2
6 years ago
1.0.0
6 years ago
1.0.0-beta.1
6 years ago
1.0.0-beta.0
6 years ago