react hook to transform a text input to currency input
npm install --save use-currency
import React, { Component } 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}
></input>
)
}
MIT © hijaz
This hook is created using create-react-hook.