Skip to content

Instantly share code, notes, and snippets.

@szympajka
Last active February 4, 2019 22:12
Show Gist options
  • Save szympajka/03554a4727e353db8fe613518446ce91 to your computer and use it in GitHub Desktop.
Save szympajka/03554a4727e353db8fe613518446ce91 to your computer and use it in GitHub Desktop.
import { createComponent, styled } from 'snabbdom-react-components'
const Box = styled.div``
const Label = styled.label``
const InputField = styled.input`
${(props, data) => {
data.attrs.type = 'text'
}}
`
const Input = (params) => createComponent({
state: () => ({ value: params.value }),
onInput: (e, state, component) => component.setState({value: e.target.value}),
render(state, component) {
return Box([
Label(params.label),
InputField({
on: {
input: component.items.onInput
}
})
])
}
})
///
const newInput = Input({ .. .})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment