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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.3
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.3
    1
  • 1.0.2
    0
  • 1.0.1
    0
  • 1.0.0
    0

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