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

Support defaultReturnValue in useFacetCallback #105

Merged
merged 1 commit into from
Dec 5, 2022

Conversation

pirelenito
Copy link
Member

The motivation is to make it easier to use callbacks constructed via the hook useFacetCallback to interoperate with other libraries.

As an example, before this change we will get a type error if we plan to use the resulting callback as a prop to a component that expects a string as a return type:

Type '() => string | unique symbol' is not assignable to type '() => string'.
  Type 'string | unique symbol' is not assignable to type 'string'.
    Type 'typeof import("c:/dev/minecraft-ui/node_modules/@react-facet/core/dist/types").NO_VALUE' is not assignable to type 'string'.ts(2322)

The new defaultReturnValue prop allow us to have a callback that can never return NO_VALUE.

@pirelenito pirelenito requested review from a team and ja-ni and removed request for a team December 5, 2022 12:55
@pirelenito pirelenito removed the request for review from ja-ni December 5, 2022 13:58
@pirelenito pirelenito merged commit 52c33cf into main Dec 5, 2022
@pirelenito pirelenito deleted the default-return-value-use-facetcallback branch December 5, 2022 14:43
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.

2 participants