feat(hooks): add useNodesInitialized

This commit is contained in:
moklick
2022-08-30 22:00:55 +02:00
parent 43e4842cd6
commit 596ddd21bc
2 changed files with 14 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
import { ReactFlowState } from '../types';
import { useStore } from './useStore';
const selector = (s: ReactFlowState) => Array.from(s.nodeInternals.values()).every((n) => n.width && n.height);
function useNodesInitialized(): boolean {
const initialized = useStore(selector);
return initialized;
}
export default useNodesInitialized;

View File

@@ -41,5 +41,7 @@ export { default as useKeyPress } from './hooks/useKeyPress';
export * from './hooks/useNodesEdgesState';
export { useStore, useStoreApi } from './hooks/useStore';
export { default as useOnViewportChange } from './hooks/useOnViewportChange';
export { default as useOnSelectionChange } from './hooks/useOnSelectionChange';
export { default as useNodesInitialized } from './hooks/useNodesInitialized';
export * from './types';