question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`node.__rf.width` and `node.__rf.height` is not ready in `onLoad`.

See original GitHub issue

I want to do manually layouting in onLoad callback. However size is not ready at that time (However DOM is ready).

It’s hard to find the proper timing for first layouting.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
moklickcommented, Feb 22, 2022

Will be fixed in v10.

1reaction
cfreecommented, Jul 16, 2021

I had the same issue and had to add a check to make sure the nodes all had dimensions before I did my layouting:

...
const nodeHasDimension = (el) => el.__rf.width && el.__rf.height;

const Builder = () => {
  const nodes = useStoreState(state => state.nodes);
  const edges = useStoreState(state => state.edges);
  const setElements = useStoreActions(actions => actions.setElements);
  const [shouldLayout, setShouldLayout] = useState(true);

  useEffect(() => {
    if (shouldLayout && nodes.length && nodes.length > 0 && nodes.every(nodeHasDimension)) {
        const elements = [...nodes, ...edges]
        const elementsWithLayout = getLayoutedElements(elements);

        setElements(elementsWithLayout);
        setShouldLayout(false);
      } 
  }, [shouldLayout, nodes, edges, setElements, setShouldLayout]);

  const onLoad = useCallback((reactFlowInstance) => {
    reactFlowInstance.fitView();
    reactFlowInstance.zoomTo(1);
  }, []);

  return (
    <div className={Styles['pane']}>
      <ReactFlow
        elements={initialElements}
        onLoad={onLoad}
        elementsSelectable={false}
      />
    </div>
  )
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

"Window.onload" not working in the Node.js - Stack Overflow
the window is the Envirmantal by the browser provide to some thig like scroll width and height add event listener window.
Read more >
the deferred dom node could not be resolved - You.com
I'm trying to make a chrome extension to fill out forms. So when the extension clicks a button to go to the next...
Read more >
rs=AGLTcCO6pCCumSPc8N96tzKlkZCmYrinkw
+c+" must not be null or undefined");if(b instanceof RegExp)throw new TypeError("First ... aspectRatio=function(){return this.width/this.height};_.g.
Read more >
How to Change Scanner Settings - Dummies.com
Choose Start→Control Panel. · Click View Scanners and Cameras. · Click any scanner in the Scanners and Cameras area and then click the...
Read more >
https://osf.io/be2cu/download?ref=54b94d4837e3cd1c...
nodeValue ; }); this. ... resolveWith(k,c),g.promise()}});var H;m.fn.ready=function(a){return ... DOCUMENT_NODE:return G.call(a,b);case Node.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found