Skip to content

Feature request: make dependency list optional #130

@juho-ylikyla

Description

@juho-ylikyla

First of all, thank you for this super useful hook!

The react useEffect hook has an optional dependency list making it possible to run the effect on each render. I would like to have a similar API in the useAsyncEffect.

Expected Behavior

I would like to write something like this...

 useAsyncEffect(function* (_, c) {
    const resultWhichChangesOnEachRender = yield* c(iWantThisToRunOnEveryRender());
  });

Current Behavior

...instead of writing something like this.

 useAsyncEffect(function* (_, c) {
    const resultWhichChangesOnEachRender = yield* c(iWantThisToRunOnEveryRender());
  }, [dependencyThatNeedsToChangeOnEachRender]);

Possible Solution

Can we just make the dependency list optional?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions