chore(useStore): cleanup
This commit is contained in:
@@ -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
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user