refactor(useNodesInit): check for handleBounds, false for no nodes
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
import { ReactFlowState } from '../types';
|
||||
import { internalsSymbol } from '../utils';
|
||||
import { useStore } from './useStore';
|
||||
|
||||
const selector = (s: ReactFlowState) => Array.from(s.nodeInternals.values()).every((n) => n.width && n.height);
|
||||
const selector = (s: ReactFlowState) => {
|
||||
if (s.nodeInternals.size === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Array.from(s.nodeInternals.values()).every((n) => n[internalsSymbol]?.handleBounds !== undefined);
|
||||
};
|
||||
|
||||
function useNodesInitialized(): boolean {
|
||||
const initialized = useStore(selector);
|
||||
|
||||
Reference in New Issue
Block a user