Skip to content

useEffect firing in children before parent #15281

Closed
@mpgon

Description

@mpgon

Do you want to request a feature or report a bug?
Feature (I believe)
What is the current behavior?
Right now, the effects in useEffect fire children-first. I know this makes sense, since the behaviour of the first render has a close correlation to cDm. However, I cannot seem to find a way to fire events parent-first. Before, I could do it with cWm, and after that was deprecated, in the constructor. How can I accomplish that with hooks?
CodeSandbox example:
https://codesandbox.io/s/035lqnozzl?fontsize=14
What is the use case?
Imagine I want to post to an external server when two components were first rendered, to measure a sort of meaningful paint.

- Component A -> post("first render"", component: A)
----
--------
------------ Component B -> post("first render", component: B)

How could I accomplish this with hooks?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions