Skip to content

Latest commit

 

History

History
29 lines (20 loc) · 795 Bytes

basic-example.md

File metadata and controls

29 lines (20 loc) · 795 Bytes

Basic Example

Here's a simple example of OneForm in action:

import {
  Field,
  OneForm,
} from '@oneform/react'

const BasicExample = () => (
  <OneFormProvider>
    <Field>
      <input name="message" />
    </Field>
  </OneFormProvider>
)

export default BasicExample

It's a pretty basic example, but you don't need to pass anything special to OneForm, just children.

Field is where the magic happens. All of your props go on your input components, Field will try its best to read your props.

Caveats

To use Field, there is a caveat. Your input component needs to have a name prop and it needs to accept a value prop. Even if it doesn't, no big deal, there's a field translation component which will customize Field for your particular components.