GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - tracksuitdev/use-imask: React hook for https://imask.js.org/

BranchesTags
Open more actions menu

Latest commit

 

History

12 Commits
12 Commits

Folders and files

NameName
Last commit message
Last commit date
example
example
 
 
src
src
 
 
test
test
 
 
.eslintrc.js
.eslintrc.js
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 
yarn.lock
yarn.lock
 
 

Repository files navigation

use-imask npm npm bundle size NPM

React hook that exposes IMask object

Installation

npm install use-imask

or if you use yarn

yarn add use-imask

Usage

const maskOptions = { mask: Number }; // make sure options don't change on each render (use constant or useMemo or ref)

function Example() {
  const [value, setValue] = useState("");

  const [ ref ] = useIMask(maskOptions, {
  // use onAccept callback instead of onChange to change value
    onAccept: e => { 
      setValue(e.target.value);
    },
  });

  return (
    <input ref={ref} value={value} />
  );
}

Props

name type description
options <M extends AnyMaskedOptions> mask options, when options change updateOptions function is called by the IMask object
onAccept (e: ChangeEvent<E>, mask: InputMask<M> | undefined) => void function called on IMask accept event
onComplete (e: ChangeEvent<E>, mask: InputMask<M> | undefined) => void function called on IMask complete event

Return value

name type description
ref RefObject<HTMLInputElement|null> apply this to your input element
maskRef RefObject<InputMask<M> | undefined> ref with IMask object

About

React hook for https://imask.js.org/

Topics

imaskjsinputmaskreactreact-hookstypescript

Resources

Readme
MIT license
Activity

Stars

4 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.