Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix stale props being passed to promiseFn when using watchFn #181

Merged
merged 4 commits into from
Nov 11, 2019

Conversation

salolivares
Copy link
Contributor

@salolivares salolivares commented Oct 17, 2019

Description

When watching for a variable changes using watchFn, the react async hook properly re-runs promiseFn but with old props passed in. This fix aims to correct that behavior.

This fixes #180

Checklist

Make sure you check all the boxes. You can omit items that are not applicable.

  • Ensure promiseFn receives updated props.
  • Added / updated the unit tests

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 17, 2019

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit dffd39f:

Sandbox Source
hungry-black-jevs3 Configuration
falling-sea-ynzsy Issue #180

@salolivares salolivares marked this pull request as ready for review October 21, 2019 03:20
@codecov
Copy link

codecov bot commented Oct 21, 2019

Codecov Report

Merging #181 into next will increase coverage by 0.14%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##             next     #181      +/-   ##
==========================================
+ Coverage   98.58%   98.73%   +0.14%     
==========================================
  Files           8        8              
  Lines         424      395      -29     
  Branches      148      143       -5     
==========================================
- Hits          418      390      -28     
+ Misses          6        5       -1
Impacted Files Coverage Δ
packages/react-async/src/useAsync.js 100% <100%> (ø)
packages/react-async/src/helpers.tsx
packages/react-async/src/reducer.ts
packages/react-async/src/Async.tsx
packages/react-async/src/propTypes.ts
packages/react-async/src/status.ts
packages/react-async/src/useAsync.tsx
packages/react-async/src/Async.js 100% <0%> (ø)
packages/react-async/src/status.js 100% <0%> (ø)
packages/react-async/src/propTypes.js 100% <0%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6bf5211...dffd39f. Read the comment docs.

Copy link
Contributor Author

@salolivares salolivares left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another solution is to add lastOptions.current = options before the load() on line 135.

packages/react-async/src/useAsync.js Outdated Show resolved Hide resolved
@Jyrno42
Copy link

Jyrno42 commented Nov 10, 2019

Any chance to get this released soon?

@ghengeveld
Copy link
Member

Thanks for reminding me. We were focused on the TypeScript migration, but that's merged now. This is looking good, so it's going out with the next release, which will be sometime this week.

@ghengeveld ghengeveld merged commit 2538607 into async-library:next Nov 11, 2019
@ghengeveld
Copy link
Member

@all-contributors Please add @salolivares for code

@allcontributors
Copy link
Contributor

@ghengeveld

I've put up a pull request to add @salolivares! 🎉

@ghengeveld
Copy link
Member

@all-contributors Please add @salolivares for bug

@allcontributors
Copy link
Contributor

@ghengeveld

I've put up a pull request to add @salolivares! 🎉

@ghengeveld ghengeveld mentioned this pull request Nov 21, 2019
@ghengeveld
Copy link
Member

@Jyrno42 I published a pre-release here: v10.0.0-alpha.0

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.

Stale data passed to promiseFn when using watchFn
3 participants