Skip to content

Instantly share code, notes, and snippets.

@niinpatel
Created February 25, 2019 14:28
Show Gist options
  • Save niinpatel/4fac8b6633a126172d8e3a4904fa2a8f to your computer and use it in GitHub Desktop.
Save niinpatel/4fac8b6633a126172d8e3a4904fa2a8f to your computer and use it in GitHub Desktop.
import React, { useState } from 'react';
const useTextField = name => {
const [value, setValue] = useState('');
const onChange = event => {
setValue(event.target.value);
};
return {
name,
value,
onChange,
placeholder: name,
};
};
const InputDemoWithHooks = () => {
const nameField = useTextField('name');
return <input type="text" {...nameField} />;
};
export default InputDemoWithHooks;
@ericallard0
Copy link

As your hook is useTextField I would expect it to return type: "text" as well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment