chore(useStore): cleanup

This commit is contained in:
moklick
2024-02-17 12:24:38 +01:00
parent cccfc21114
commit f14480dc89
2 changed files with 3 additions and 5 deletions
+2 -4
View File
@@ -1,6 +1,5 @@
import { useContext, useMemo } from 'react'; import { useContext, useMemo } from 'react';
import { useStoreWithEqualityFn as useZustandStore } from 'zustand/traditional'; import { useStoreWithEqualityFn as useZustandStore } from 'zustand/traditional';
import type { StoreApi } from 'zustand';
import { errorMessages } from '@xyflow/system'; import { errorMessages } from '@xyflow/system';
import StoreContext from '../contexts/RFStoreContext'; import StoreContext from '../contexts/RFStoreContext';
@@ -8,8 +7,6 @@ import type { ReactFlowState } from '../types';
const zustandErrorMessage = errorMessages['error001'](); const zustandErrorMessage = errorMessages['error001']();
type ExtractState = StoreApi<ReactFlowState> extends { getState: () => infer T } ? T : never;
/** /**
* Hook for accessing the internal store. Should only be used in rare cases. * Hook for accessing the internal store. Should only be used in rare cases.
* *
@@ -18,7 +15,8 @@ type ExtractState = StoreApi<ReactFlowState> extends { getState: () => infer T }
* @param equalityFn * @param equalityFn
* @returns The selected state slice * @returns The selected state slice
*/ */
function useStore<StateSlice = ExtractState>(
function useStore<StateSlice = unknown>(
selector: (state: ReactFlowState) => StateSlice, selector: (state: ReactFlowState) => StateSlice,
equalityFn?: (a: StateSlice, b: StateSlice) => boolean equalityFn?: (a: StateSlice, b: StateSlice) => boolean
) { ) {
+1 -1
View File
@@ -45,7 +45,7 @@ import type {
OnBeforeDelete, OnBeforeDelete,
} from '.'; } from '.';
export type ReactFlowStore<NodeType extends Node> = { export type ReactFlowStore<NodeType extends Node = Node> = {
rfId: string; rfId: string;
width: number; width: number;
height: number; height: number;