Skip to content

Instantly share code, notes, and snippets.

@francodalessio
Created March 31, 2020 22:59
Show Gist options
  • Save francodalessio/4510259192e6b393a89bb2acc716fafa to your computer and use it in GitHub Desktop.
Save francodalessio/4510259192e6b393a89bb2acc716fafa to your computer and use it in GitHub Desktop.
import { useState } from "react";
function useInput(initialValue) {
const [state, setState] = useState(initialValue);
const handleChange = e => {
setState(e.target.value);
};
const reset = () => {
setState("");
};
return [state, handleChange, reset];
}
export default useInput;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment