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

useCustomCompareMemo assigns unknown type to its return value #975

Closed
ArttuOll opened this issue Oct 22, 2022 · 1 comment
Closed

useCustomCompareMemo assigns unknown type to its return value #975

ArttuOll opened this issue Oct 22, 2022 · 1 comment
Labels

Comments

@ArttuOll
Copy link
Contributor

Prior Issues

I discovered this issue while implementing #871. I am finished with it, but I think this issue should be solved before opening a PR.

What is the current behavior?

The type of the value returned by useCustomCompareMemo is unknown regardless of what the return type of its factory function actually is. This is problematic, because unknown is pretty unusable and requires casting to the actual type to be usable.

In the docs, the type reference of useCustomCompareMemo says that the return type should be ReturnType<Factory>, ie. the return type of the given factory function, but it is not.

Steps to Reproduce

Open this CodeSandbox and hover your mouse on top of the value variable and see its type.

What is the expected behavior?

The return type of useCustomCompareMemo should match the return type of its factory function, just like it does when using useMemo.

Environment Details

  • @react-hookz/web version: latest
ArttuOll added a commit to ArttuOll/react-hookz-web that referenced this issue Oct 22, 2022
…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
ArttuOll added a commit to ArttuOll/react-hookz-web that referenced this issue Oct 22, 2022
…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
github-actions bot pushed a commit that referenced this issue 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 issue has been resolved 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

No branches or pull requests

2 participants