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:
;
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 or string[] |
|
The currency to which it is converted |
base | string |
|
Base currency |
rates | Rates | {} |
Currency rates |
keepPrecision | boolean | true |
true (return exact values), false (return values rounded to 2 places) |
Returned Values
Type | Description |
---|---|
number or object with currencies passed in to |
Converted value |
Example
;; const App = { const rates = GBP: 092 EUR: 100 CHF: 108 USD: 112 ; /* * 1. With single `to` value */ const currency = ; return <p>USD to CHF: currency</p> ; /* * 2. With multiple `to` values */ const chf gbp = ; return <> <p>USD to CHF: chf</p> <p>USD to GBP: gbp</p> </> ;}; ;
License
This project is licensed under the MIT License © 2020-present Jakub Biesiada