1.0.3 • Published 2 years ago

react-use-password v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

usePassword

Example

Installation

$ npm install react-use-password

API

const { passwordValue, onPasswordChanged } = usePassword();

You can destructuring passwordValue it has password and passwordHidden

password = password that show in input field

passwordHidden = real password for use

Option

you can add an option like this

const { passwordValue, onPasswordChanged } = usePassword({
  length: 2,
  mask: "*",
  timeout: 2000,
});

length = length of password that show before change to password type

mask = symbol that will appear for hide password

timeout = timeout for hide password after typed


Example

import { usePassword } from "react-use-password";

const App = () => {
  const { passwordValue, onPasswordChanged } = usePassword();

  return (
    <div className="App">
      <header className="App-header">
        <div>
          <input
            name="password"
            onChange={(event) => onPasswordChanged(event)}
            value={passwordValue.password}
          />
        </div>
      </header>
    </div>
  );
};

Type

type usePassword = {
  passwordValue: {
    password: string,
    passwordHidden: string,
  },
  onPasswordChanged: (EventTarget) => void,
};

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago