feat(hooks): add useNodesInitialized
This commit is contained in:
12
packages/core/src/hooks/useNodesInitialized.ts
Normal file
12
packages/core/src/hooks/useNodesInitialized.ts
Normal 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;
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user