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(useCustomCompareMemo): Correctly infer factory function return type #976

Merged
merged 1 commit into from Oct 22, 2022

Conversation

ArttuOll
Copy link
Contributor

What is the current behavior, and the steps to reproduce the issue?

Described in #975.

What is the expected behavior?

Described in #975.

How does this PR fix the problem?

Change the type of the useCustomCompareMemo factory function to include a generic type parameter for the return type. This generic type is then passed to the underlying useMemo, guaranteeing correct return type.

Checklist

  • Have you read contribution guideline?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Is there an existing issue for this PR?
  • Have the files been linted and formatted?
  • Have the docs been updated to match the changes in the PR?
  • Have the tests been updated to match the changes in the PR?
  • Have you run the tests locally to confirm they pass?

…rned by the factory function

Change the return type to the type returned by the factory function instead of unknown. This makes
the hook work the same way as useMemo.

fix react-hookz#975
@codecov
Copy link

codecov bot commented Oct 22, 2022

Codecov Report

Merging #976 (99a7c9e) into master (8411792) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #976   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           60        60           
  Lines         1060      1060           
  Branches       184       184           
=========================================
  Hits          1060      1060           
Impacted Files Coverage Δ
src/useCustomCompareMemo/useCustomCompareMemo.ts 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@xobotyi
Copy link
Contributor

xobotyi commented Oct 22, 2022

About the merging policy.

We're doing the squash and merge to maintain changelogs (which are generated from commits history automatically) clean and descriptive.

You're allowed to do it yourself after at least one approve from other members of team and CI pass.

@ArttuOll
Copy link
Contributor Author

About the merging policy.

We're doing the squash and merge to maintain changelogs (which are generated from commits history automatically) clean and descriptive.

You're allowed to do it yourself after at least one approve from other members of team and CI pass.

Approving review, then squash and merge. Got it.

@ArttuOll ArttuOll merged commit a625c55 into react-hookz:master Oct 22, 2022
@ArttuOll ArttuOll deleted the pr/fix-975 branch October 22, 2022 20:05
github-actions bot pushed a commit that referenced this pull request Oct 22, 2022
## [16.0.1](v16.0.0...v16.0.1) (2022-10-22)

### Bug Fixes

* **useCustomCompareMemo:** Correctly infer the type of the value returned by the factory function ([#976](#976)) ([a625c55](a625c55)), closes [#975](#975)
@xobotyi
Copy link
Contributor

xobotyi commented Oct 22, 2022

🎉 This PR is included in version 16.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

2 participants