How to use the react-fetching-library.useMutation function in react-fetching-library

To help you get started, we’ve selected a few react-fetching-library examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marcin-piela / react-fetching-library / examples / crud-form / src / SubmissionFormContainer.tsx View on Github external
const SubmissionFormContainer: React.FC = () => {
  const { mutate, error, status, reset } = useMutation(submitFormAction);

  const handleSubmit = async (values: SubmissionValues, actions: FormikActions) => {
    reset();
    try {
      await mutate(values);
      actions.resetForm();
    } catch {
      throw new Error('An unexpected error occurred');
    } finally {
      actions.setSubmitting(false);
    }
  };

  return (
    
      {error && (

react-fetching-library

Simple and powerful API client for react. Use hooks or FACC's to fetch data in easy way. No dependencies! Just react under the hood.

MIT
Latest version published 4 years ago

Package Health Score

51 / 100
Full package analysis