refactor(useStore): show troubleshooting link

This commit is contained in:
moklick
2022-08-06 17:19:54 +02:00
parent 753f442468
commit 5cf4520992

View File

@@ -4,12 +4,13 @@ import { StoreApi, useStore as useZustandStore } from 'zustand';
import StoreContext from '../contexts/RFStoreContext';
import { ReactFlowState } from '../types';
const errorMessage = 'Seems like you have not used zustand provider as an ancestor.';
const errorMessage =
'[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#100';
type ExtractState = StoreApi<ReactFlowState> extends { getState: () => infer T } ? T : never;
function useStore<StateSlice = ExtractState>(
selector: (state: ExtractState) => StateSlice,
selector: (state: ReactFlowState) => StateSlice,
equalityFn?: (a: StateSlice, b: StateSlice) => boolean
) {
const store = useContext(StoreContext);