Skip to content

useLayoutEffect and useEffect odd behavior #97

@leeoniya

Description

@leeoniya

hey @localvoid think i found a bug?

i'd like to use useLayoutEffect to measure the rendered DOM. i expcted it to fire once the DOM has been flushed/synced. but it fires before anything is rendered.

  useLayoutEffect(c, () => {
    console.log('useLayoutEffect!');
  })();

however, if i add a useEffect above it, then the useEffect fires after the DOM has been flushed/synced, then useLayoutEffect also fires.

  useEffect(c, () => {
    console.log('useEffect!');
  })();

  useLayoutEffect(c, () => {
    console.log('useLayoutEffect!');
  })();
  • i did not expect useLayoutEffect to fire before DOM sync
  • i did not expect useEffect to affect useLayoutEffect

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions