Children component mounted before parent compoent.
See original GitHub issueHi there. Here is my page:
I want get host detail from main view.
I think it’s should be Main view mounted...
--> Drill view mounted...
, but actually, it’s Drill view mounted...
--> Main view mounted...
.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:4
- Comments:19 (5 by maintainers)
Top Results From Across the Web
Mounted in child component executes before parent ...
The issue I am facing here is that the child component mounted is executed before the parent child created. I am sending props...
Read more >Vue Parent and Child lifecycle hooks | by Brock Reece - Medium
A component becomes reactive just before the Created hook is fired, this means it will start to track changes of it's props before...
Read more >Order of lifecycle hooks for parent and child - Vue Forum
I have seen For example: mounted in a child components gets executed first and beforeCreate in parent component gets executed later.
Read more >The mystery of React Element, children, parents and re-renders
Looking into what is React Element, exploring various children vs parents relationship in React, and how they affect re-renders.
Read more >Child route component mounted twice and before parent
I can say that child components are mounted before parents. It's in the docs.
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
As far as I know this is expected. By the time
componentDidMount
fires you can do DOM manipulation so it makes sense that parent only receives it after children are mounted. That said you can usecomponentWillMount
which fires in the opposite direction, parents first.a live demo
https://33qrr.csb.app/
https://codesandbox.io/s/react-parent-child-lifecycle-order-33qrr
create order
destroy order