1.0.1 • Published 4 years ago

use-currency v1.0.1

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

use-currency

react hook to transform a text input to currency input

NPM JavaScript Style Guide

Install

npm install --save use-currency

Usage

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>
  )
}

![](https://www.hassanijaz.com/downloads/use-currency.gif)

License

MIT © hijaz


This hook is created using create-react-hook.