You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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.
fixreact-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.
fixreact-hookz#975
## [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)
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
isunknown
regardless of what the return type of its factory function actually is. This is problematic, becauseunknown
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 beReturnType<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 usinguseMemo
.Environment Details
@react-hookz/web
version: latestThe text was updated successfully, but these errors were encountered: