Skip to content

useEffect is synchronous? #161

Open
Open
@dy

Description

@dy

I noticed that

  let { component, useState, useEffect, State } = await import("haunted")

  let state = new State(() => {
    update();
  });

  function update() {
    state.run(() => {
      useEffect(() => { console.log(1) })
      let [s, setS] = useState(0)

      useEffect(() => setS(1), [])
      useEffect(() => console.log(2), [])
      useEffect(() => console.log(3), [])

      return;
    });
    state.runEffects()
  }

  update();

Never logs 2, 3 - is useEffect synchronous by design?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions