All files / libs/ext/formik/src/lib/components/formik-autosave FormikAutosave.tsx

100% Statements 21/21
100% Branches 1/1
100% Functions 1/1
100% Lines 21/21

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 221x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import { type FormikValues } from 'formik';
import { Fragment, memo, type ReactNode } from 'react';
 
import { useFormikAutosave, type UseFormikAutosaveOptions } from '../../hooks/use-formik-autosave/useFormikAutosave';
 
export type FormikAutosaveProps<TValues extends FormikValues = FormikValues> = UseFormikAutosaveOptions<TValues> & {
  /** Children if wrapping content. */
  readonly children?: ReactNode;
};
 
const FormikAutosaveBase = function FormikAutosave<TValues extends FormikValues = FormikValues>({
  onSave,
  timeoutMs = undefined,
  children = undefined,
}: FormikAutosaveProps<TValues>) {
  useFormikAutosave({ onSave, timeoutMs });
 
  return <Fragment>{children}</Fragment>;
};
 
export const FormikAutosave = memo(FormikAutosaveBase) as typeof FormikAutosaveBase;