Skip to content
Irham Putra edited this page Apr 13, 2020 · 7 revisions

Documentation

Content

useFormatMoney

setFormat()

params:

  • amount type number
  • locale type string (Popular locale: 'id' for Indonesia, 'us' for United States, 'de' for Germany)
  • currency type string ('EUR', 'IDR, 'USD')

You can format your number from your input field

import { useFormatMoney } from 'react-use-pkg';

const Component = () => {
   const {value, setFormat} = useFormatMoney()

   return (
      <div>
         <button onClick(() => setFormat(1000000, 'us', 'USD'))>Format money!</button>
         {value}
      </div>
   )
}

useZipCode

This hooks has asnyc function, so it might be a take a while to processed.

Available only in Germany ('de') and US ('us')

import { useZipCode } from 'react-use-pkg';

const Component = () => {
   const {value, setCodeCountry} = useZipCode()

   return (
      <div>
         <button onClick(() => setCodeCountry('de', 04177))>Get data</button>
         {JSON.stringify(value, null, 2)}
      </div>
   )
}

useFetchWithCORS

If you have struggle with CORS already, this hooks will fix it in client

import { useFetchWithCORS } from 'react-use-pkg';

const Component = () => {
   const {data, setURI} = useZipCode()

   return (
      <div>
         <button onClick(() => setCodeCountry('de', 04177))>Get data</button>
         {JSON.stringify(value, null, 2)}
      </div>
   )
}
Clone this wiki locally