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.

Children component mounted before parent compoent.

See original GitHub issue

Hi there. Here is my page:

image

image

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:closed
  • Created 8 years ago
  • Reactions:4
  • Comments:19 (5 by maintainers)

github_iconTop GitHub Comments

36reactions
gaearoncommented, Dec 26, 2015

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 use componentWillMount which fires in the opposite direction, parents first.

4reactions
xgqfrmscommented, May 18, 2020

a live demo

react-parent-child-lifecycle-order

https://33qrr.csb.app/

https://codesandbox.io/s/react-parent-child-lifecycle-order-33qrr

create order


parent constructor
parent WillMount
parent render

child constructor
child WillMount
child render
child DidMount

parent DidMount

destroy order

parent WillUnmount

child WillUnmount

// child unmount

// parent unmount



Read more comments on GitHub >

github_iconTop 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 >

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