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.

componentDidMount was called before DOM attached

See original GitHub issue

Hi, I appreciated your work on explaining React internal. But I think there is something wrong about life-cycle. https://gist.github.com/vanhtuan0409/b3bdfb7bfdb50edd45269a95e846c69f The above snippet shows that componentDidMount was called before real DOM is attached to the document. In the real version of React, I think componentDidMount is ensured to be called after the DOM was attached

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
sweetpalmacommented, May 31, 2018

@vanhtuan0409 Great - I like it, made a few touch ups and added you AUTHORS list. Thanks for contribution!

1reaction
vanhtuan0409commented, May 31, 2018

Hey I opened a PR to address this issue https://github.com/sweetpalma/gooact/pull/4 My idea is that we can attach VDOM element as soon as it was created. Then we can incrementally attach its children later. Not sure if I broke anything, if you have time then take a look

Read more comments on GitHub >

github_iconTop Results From Across the Web

componentDidMount called before real DOM is available
I understood that this method was called after rendering the component, which is at the end to write the real DOM I assume....
Read more >
componentDidMount, there is no guarantee that the DOM ...
You could attach it before calling React, and then you'd always be "in the document" by the time componentDidMount or ref callback fires....
Read more >
React lifecycle methods: An approachable tutorial with examples
The constructor method is called before the component is mounted to the DOM. In most cases, you would initialize state and bind event...
Read more >
How to understand a component's lifecycle methods in ReactJS
componentDidMount()​​ This method is called after the component gets mounted on the DOM. Like componentWillMount, it is called once in a ...
Read more >
ReactJS componentDidMount() Method - GeeksforGeeks
The componentDidMount() method allows us to execute the React code when the component is already placed in the DOM (Document Object Model).
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