Skip to content

Instantly share code, notes, and snippets.

@mDibyo
Created December 27, 2018 09:01
Show Gist options
  • Save mDibyo/d693daa3c63c39b065a2648891d164d0 to your computer and use it in GitHub Desktop.
Save mDibyo/d693daa3c63c39b065a2648891d164d0 to your computer and use it in GitHub Desktop.
class HookedInput extends React.PureComponent {
render() {
// `withHook` creates a new function component that calls `useFormInput`
// that passes the return value to its children.
const WithFormInputProps = withHook(useFormInput);
return (
<WithFormInputProps>
{({ value, onChange }) => <input value={value} onChange={onChange} />}
</WithFormInputProps>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment