react-local-currency

1.0.0 • Public • Published

React Local Currency

Travis npm package Coveralls

Installation

First, install the component:

yarn add react-local-currency

or

npm i react-local-currency --save

Usage

  import LocalCurrency from 'react-local-currency'
 
  ...
 
  <LocalCurrency
    amount={7} // Default price
    base='USD' // Default currency
    IPDATA_API_KEY='?' // Get the api key from http://ipdata.co
    OXR_API_ID='?' // Get the api id from https://openexchangerates.org
    render={({ data, loading, error }) => {
      if (error) return `Error! ${error.message}`
 
      if (loading) return 'Loading ...'
 
      if (!data) return null
 
      return (
        <div>
          <h3>
            My service price: <strong>7 USD.</strong>
          </h3>
          <h3>
            My currency based on my IP: <strong>{`${data.currency}`}</strong>
          </h3>
          <h3>
            My local price is: <strong>{`${data.amount} ${data.currency}`}</strong>
          </h3>
        </div>
      )
    }}
  />

To see a full example, look at the demo

Authors

Sponsored by

License

MIT license. Copyright © 2018.

Readme

Keywords

Package Sidebar

Install

npm i react-local-currency

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

142 kB

Total Files

15

Last publish

Collaborators

  • slorenzo