WIP: migrated store and useSvelteFlow hook to signals & solved state propagation for provider
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { key } from '$lib/store';
|
||||
import type { StoreContext } from '$lib/store/types';
|
||||
import { getContext } from 'svelte';
|
||||
|
||||
export function derivedWarning(functionName: string) {
|
||||
const storeContext = getContext<StoreContext>(key);
|
||||
|
||||
if (!storeContext) {
|
||||
throw new Error(
|
||||
`In order to use ${functionName}() you need to wrap your component in a <SvelteFlowProvider />`
|
||||
);
|
||||
}
|
||||
|
||||
if (storeContext.provider && !$effect.tracking()) {
|
||||
console.warn(
|
||||
`Use $derived(${functionName}()), when not calling inside a child of the <SvelteFlow /> component.`
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user