sanniassin / react-input-mask

Input masking component for React. Made with attention to UX.
MIT License
2.24k stars 255 forks source link

Given example program not working #269

Closed mk48 closed 3 years ago

mk48 commented 3 years ago

The given example in the Readme.md file seems not working. I have included a code sandbox link.

Below is the document example image

Code sandbox screen image

Full code

import React, { useState } from "react";
import InputMask from "react-input-mask";

const firstLetter = /(?!.*[DFIOQU])[A-VXY]/i;
const letter = /(?!.*[DFIOQU])[A-Z]/i;
const digit = /[0-9]/;
const msk = [firstLetter, digit, letter, " ", digit, letter, digit];

const Txt = () => {
  const [value, setValue] = useState<string>("");
  const onChange = (e: any) => {
    setValue(e.target.value);
    //console.log(e);
  };
  return (
    <InputMask
      mask={msk}
      onChange={onChange}
      value={value}
      alwaysShowMask={true}
    />
  );
};

export default Txt;

Code sandbox link https://codesandbox.io/s/input-mask-uwduh?file=/src/Txt.tsx:0-575

Am I missing anything?

TimofeiKurohtin commented 3 years ago

It only works with the version 3.0.0-alpha.0, consider checking your version

mk48 commented 3 years ago

Thanks, it's working in the 3.0.0-alpha.0