4.0.6 • Published 8 days ago

@drieam/final-form-react-query v4.0.6

Weekly downloads
-
License
MIT
Repository
-
Last release
8 days ago

@drieam/final-form-react-query

Convenient component and helpers for using React Final Form in combination with React Query.

Installation

Install @drieam/final-form-react-query and its peer dependencies:

$ pnpm add @drieam/final-form-react-query @drieam/react-query react-query react-final-form final-form

Usage

To use a React Query mutation with Final Form, use the Form component:

import { useUpdate } from "@drieam/react-query";
import { Form } from "@drieam/final-form-react-query";
import { Field } from "react-final-form";

interface Label {
  id: number;
  name: string;
}

interface UpdateLabel {
  name: string;
}

interface Props {
  label: Label;
}

const LabelUpdateForm = (label: Label) => {
  const { mutate } = useUpdate<Label, {}, UpdateLabel>(`/api/v1/labels/${label.id}`);

  return (
    <Form mutate={mutate} initialValues={label}>
      {({ handleSubmit }) => (
        <form onSubmit={handleSubmit}>
          <div>
            <label>Name</label>
            <Field name="name" component="input" placeholder="Name" />
          </div>
          <button type="submit">Save</button>
        </form>
      )}
    </Form>
  );
};

Components and utilities

  • Components
    • Form
  • Utilities
    • convertRequestErrorToSubmissionErrors
4.0.6

8 days ago

4.0.5

9 days ago

4.0.4

15 days ago

4.0.3

15 days ago

4.0.2

5 months ago

4.0.1

10 months ago

4.0.0

1 year ago

3.3.0

2 years ago

3.2.0

2 years ago

3.1.3

2 years ago

3.1.2

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.0

2 years ago

2.0.0

2 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago