componentDidMount was called before DOM attached
See original GitHub issueHi, 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:
- Created 5 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@vanhtuan0409 Great - I like it, made a few touch ups and added you AUTHORS list. Thanks for contribution!
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