Skip to content

Instantly share code, notes, and snippets.

@mfrancois3k
Forked from Kelin2025/1.Field.tsx
Created May 29, 2022 07:00
Show Gist options
  • Save mfrancois3k/707cf52e6cd5b43ad8dc17acbd6300ae to your computer and use it in GitHub Desktop.
Save mfrancois3k/707cf52e6cd5b43ad8dc17acbd6300ae to your computer and use it in GitHub Desktop.
export const NameField = createField({
view: ({ value, onChange }) => <Input value={value} onChange={onChange} />
})
export const SaveButton = createButton({
type: "save",
text: () => "Save User"
})
import { saveUser } from '~api'
import { NameField } from './0.NameField.ts'
import { SaveButton } from './1.SaveButton.ts'
const $form = createStoreObject({
name: NameField.$value
})
forward({
from: sample($form, SaveButton.pressed),
to: saveUser
})
const Form = () => {
return <form onSubmit={SaveButton.pressed}>
<NameField />
<SaveButton />
</form>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment