Skip to content

Instantly share code, notes, and snippets.

@nadeesha
Created February 9, 2019 23:35
Show Gist options
  • Save nadeesha/cf5942bab7a14faae508f123d33bf3f1 to your computer and use it in GitHub Desktop.
Save nadeesha/cf5942bab7a14faae508f123d33bf3f1 to your computer and use it in GitHub Desktop.
// https://github.com/acdlite/recompose/blob/master/docs/API.md
const enhance = compose(
withState('value', 'updateValue', ''),
withHandlers({
onChange: props => event => {
props.updateValue(event.target.value)
},
onSubmit: props => event => {
event.preventDefault()
submitForm(props.value)
}
})
)
const Form = enhance(({ value, onChange, onSubmit }) =>
<form onSubmit={onSubmit}>
<label>Value
<input type="text" value={value} onChange={onChange} />
</label>
</form>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment