1.2.3 • Published 3 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-hooks
Or Yarn:
$ yarn add react-currency-hooks
Getting 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
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