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
-
Strict Typing Implementation:
- Introduced strict typing across various components and hooks to enhance type safety and reduce runtime errors.
- Updated
useFormProgress
andAutoSaveFormikForm
to use generic types for better type inference and validation.
-
Custom Hook Enhancements:
- Refactored
useFormProgress
to include additional properties such asfetchInitialValues
for asynchronous initial value fetching. - Improved error handling and logging within the custom hook to provide better debugging information.
- Refactored
-
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.
- Refactored
-
Deprecation Notices:
- Marked
useProgress
anduseSaveProgress
as deprecated in favor of the newuseFormProgress
hook. - Updated documentation to guide developers towards using the new hook.
- Marked
-
Code Cleanup and Optimization:
- Removed redundant code and improved overall code readability.
- Ensured consistent coding standards and formatting across the modified files.
-
Bug Fixes:
- Fixed issues related to local storage handling and data persistence in
useFormProgress
. - Addressed potential race conditions in the initialization logic of
useFormProgress
.
- Fixed issues related to local storage handling and data persistence in
Migration Instructions
If you are upgrading from a previous version, please note the following changes:
- The
useSaveProgress
hook has been renamed touseFormProgress
. You can still useuseSaveProgress
anduseProgress
for backwards compatibility, but it is recommended to switch touseFormProgress
. - The
AutoSaveForm
component has been renamed toAutoSaveFormikForm
. You can still useAutoSaveForm
for backwards compatibility, but it is recommended to switch toAutoSaveFormikForm
.
To migrate, follow these steps:
- Replace all instances of
useSaveProgress
anduseProgress
withuseFormProgress
. - Replace all instances of
AutoSaveForm
withAutoSaveFormikForm
.
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