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.
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:
The new
defaultReturnValue
prop allow us to have a callback that can never returnNO_VALUE
.