🐛 Fix deprecated zustand dependencies

This commit is contained in:
Meier Lukas
2023-08-09 21:41:57 +02:00
parent d9eec612d8
commit db8d88affc
5 changed files with 94 additions and 130 deletions

View File

@@ -1,4 +1,4 @@
import { create } from 'zustand';
import { createWithEqualityFn } from 'zustand/traditional';
import { ServerSidePackageAttributesType } from '../../server/getPackageVersion';
@@ -7,9 +7,12 @@ interface PackageAttributesState {
setInitialPackageAttributes: (attributes: ServerSidePackageAttributesType) => void;
}
export const usePackageAttributesStore = create<PackageAttributesState>((set) => ({
attributes: { packageVersion: undefined, environment: 'test', dependencies: {} },
setInitialPackageAttributes(attributes) {
set((state) => ({ ...state, attributes }));
},
}));
export const usePackageAttributesStore = createWithEqualityFn<PackageAttributesState>(
(set) => ({
attributes: { packageVersion: undefined, environment: 'test', dependencies: {} },
setInitialPackageAttributes(attributes) {
set((state) => ({ ...state, attributes }));
},
}),
Object.is
);