Skip to content

2.0.0

Latest
Compare
Choose a tag to compare
@murageh murageh released this 03 Dec 08:27
f8c89c1

Release Notes: Version 2.0.0

We are excited to announce the release of version 2.0.0 of @crispice/save-progress. This major release includes significant improvements, new features, and important changes to enhance the functionality and usability of the library.

Major Changes and Enhancements

  1. Strict Typing Implementation:

    • Introduced strict typing across various components and hooks to enhance type safety and reduce runtime errors.
    • Updated useFormProgress and AutoSaveFormikForm to use generic types for better type inference and validation.
  2. Custom Hook Enhancements:

    • Refactored useFormProgress to include additional properties such as fetchInitialValues for asynchronous initial value fetching.
    • Improved error handling and logging within the custom hook to provide better debugging information.
  3. Component Refactoring:

    • Refactored AutoSaveFormikForm to ensure compatibility with Formik context and improve the auto-save functionality.
    • Added memoization to AutoSaveFormikForm to prevent unnecessary re-renders and optimize performance.
  4. Deprecation Notices:

    • Marked useProgress and useSaveProgress as deprecated in favor of the new useFormProgress hook.
    • Updated documentation to guide developers towards using the new hook.
  5. Code Cleanup and Optimization:

    • Removed redundant code and improved overall code readability.
    • Ensured consistent coding standards and formatting across the modified files.
  6. Bug Fixes:

    • Fixed issues related to local storage handling and data persistence in useFormProgress.
    • Addressed potential race conditions in the initialization logic of useFormProgress.

Migration Instructions

If you are upgrading from a previous version, please note the following changes:

  1. The useSaveProgress hook has been renamed to useFormProgress. You can still use useSaveProgress and useProgress for backwards compatibility, but it is recommended to switch to useFormProgress.
  2. The AutoSaveForm component has been renamed to AutoSaveFormikForm. You can still use AutoSaveForm for backwards compatibility, but it is recommended to switch to AutoSaveFormikForm.

To migrate, follow these steps:

  1. Replace all instances of useSaveProgress and useProgress with useFormProgress.
  2. Replace all instances of AutoSaveForm with AutoSaveFormikForm.

Example migration:

Before:

import {useSaveProgress} from "@crispice/save-progress";
import {AutoSaveForm} from "@crispice/save-progress";

const MyFormComponent = () => {
    const [values, updateValues, deleteValues] = useSaveProgress({key: 'user-form'});

    return (
        // ... formik wrapper
        <AutoSaveForm saveFunction = {updateValues} />
        // ... rest of the form
        );
}

After:

import {useFormProgress} from "@crispice/save-progress";
import {AutoSaveFormikForm} from "@crispice/save-progress";

const MyFormComponent = () => {
    // const [values, updateValues, deleteValues] = useFormProgress({dataKey: 'user-form'}); // No need to have this line anymore

    return (
        <AutoSaveFormikForm dataKey="user-form"> // No need to pass the saveFunction prop. You could provide the `initialValues` prop but  I don't see why you would need to.
            {/* form elements */} 
        < /AutoSaveFormikForm>
    );
}

Additional Notes

  • This release aims to improve the maintainability and robustness of the codebase by leveraging TypeScript's strict typing features.
  • Developers are encouraged to review the updated documentation and migrate to the new useFormProgress hook.

We hope you enjoy the new features and improvements in this release. Thank you for using @crispice/save-progress!

Full Changelog: 1.0.11...2.0.0