react hook to transform a text input to currency input
npm install --save use-currency
import React, { useRef } from 'react'
import { useCurrency } from 'use-currency'
const Example = () => {
const inputRef = useRef()
const initialValue = "123456"
const [currency, setCurrency, handleKeyDown] = useCurrency(initialValue, inputRef)
return (
<input
type="text"
ref={inputRef}
onKeyDown={handleKeyDown}
onChange={setCurrency}
value={currency}
/>
)
}
MIT © hijaz
This hook is created using create-react-hook.