useInput hook

DEMO
Console
This a custom hook that allows us to succinctly capture form inputs. This is particuarly useful when building long forms.
UseInputDemo.jsx

useInput.jsx
const UseInputDemo = () => {
  const name = useInput("");
  console.log(name);

  return (
    <Input placeholder="Enter your name..." {...name} />
  );
};

export default UseInputDemo;

Note: Code snippets do not include styling details unless they are the focus of the exercise.

Copyright © 2022 Explore React