0.2.13 • Published 12 months ago

mantine-form-context v0.2.13

Weekly downloads
-
License
-
Repository
github
Last release
12 months ago

Form component

import {Form, useFormContext} from "mantine-form-context"

function Nested() {
  const [f, _] = useFormContext<MyFormValues>()
  // f is same value as useForm returns
  // _ is a proxy object that gives access to all property paths (also nested objects and array paths can be resolved)
  return (
    <TextInput
      label="Name"
      placeholder="Name"
      {...f.getInputProps(_.name._PATH_)}
    />
  )
}

function Example() {
  return (
    // wraps a useForm in a context
    <Form<MyFormValues>
      initialValues={{ name: "John Doe" }}
      onSubmit={values => {
        console.log("submitting", values)
      }}
    >
      {(f, _) => (
        <>
          <TextInput
            label="Name"
            placeholder="Name"
            {...f.getInputProps(_.name._PATH_)}
          />
          <Nested />
        </>
      )}
    </Form>
  )
}
0.2.13

12 months ago

0.2.12

12 months ago

0.2.11

12 months ago

0.2.10

12 months ago

0.2.7

12 months ago

0.2.6

12 months ago

0.2.9

12 months ago

0.2.8

12 months ago

0.2.3

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.2.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago