@barrybtw/inputhook

1.0.3 • Public • Published

inputhook

Simple React Hook made for binding a state, resetfunction and bindvalue to an input.

Usage/Examples

import useInput from "@barrybtw/inputhook";

const InputExample = () => {
  const [name, nameBinding, nameReset] = useInput("");

  const handleSubmitEvent = (submitEvent) => {
    submitEvent.preventDefault();
    console.log(name); // Logs the value of the input at the time.
    nameReset(); // Resets the input field and state
  };

  return (
    <form onSubmit={handleSubmitEvent}>
      <label>First Name</label>
      <input {...nameBinding} placeholder={"Begin writing..."} />
    </form>
  );
};

Package Sidebar

Install

npm i @barrybtw/inputhook

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

1.8 kB

Total Files

3

Last publish

Collaborators

  • barrybtw