Skip to content

Conversation

xnmeet
Copy link

@xnmeet xnmeet commented Nov 19, 2024

Description

When useAsyncFn is used and the given initial value loading is true, subsequent fetch will not be able to update the loading state

  const [state, fetch] = useAsyncFn(
    async () => {
      await sleep();
      return 'hello';
    },
    undefined,
    { loading: true },
  );

  console.log(state.loading); // once to false and don't change again

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as before)

Checklist

  • Read the Contributing Guide
  • Perform a code self-review
  • Comment the code, particularly in hard-to-understand areas
  • Add documentation
  • Add hook's story at Storybook
  • Cover changes with tests
  • Ensure the test suite passes (yarn test)
  • Provide 100% tests coverage
  • Make sure code lints (yarn lint). Fix it with yarn lint:fix in case of failure.
  • Make sure types are fine (yarn lint:types).

@xnmeet xnmeet changed the title WIP: fix: initial loading unable to update correctly fix: initial loading unable to update correctly Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant