4.1.2 • Published 1 year ago
@drieam/final-form-react-query v4.1.2
@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-formUsage
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.1.0
1 year ago
4.1.2
1 year ago
4.1.1
1 year ago
4.0.6
1 year ago
4.0.5
1 year ago
4.0.4
1 year ago
4.0.3
1 year ago
4.0.2
2 years ago
4.0.1
2 years ago
4.0.0
3 years ago
3.3.0
3 years ago
3.2.0
3 years ago
3.1.3
4 years ago
3.1.2
4 years ago
3.1.1
4 years ago
3.1.0
4 years ago
3.0.0
4 years ago
2.0.0
4 years ago
1.1.1
4 years ago
1.1.0
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago