AsyncHookResult<T> is confusing & potentially buggy defined this way
See original GitHub issueFeature Request
I would like to open a discussion about changing this
export type AsyncHookResult<T> = {
loading: boolean,
result: T | -1 | false | 'unknown',
}
Strongly typed languages like reasonml cannot just accept such things as “type1 or type2” (they provide variant for this usages). Since we are writing a zero-cost bindings (ie: just typing interface like flow & ts that doesn’t create extra js cost) https://github.com/reason-react-native/device-info it would be nice to have a reference that is more specific for each hooks & that doesn’t try to mix too many kind of result.
Why it is needed
I am updating reasonml zero cost bindings & struggle on that. I cannot write zero cost bindings with this current type if I blindly follow them. I think it could be a good idea to provide a better interface, more easy to type & maybe more intuitive.
Possible implementation
It seems some values are only used in some edge cases, so we could try to provide more types to be more specific? Should not be that hard to not rely on a single type for containing hooks results.
Code sample
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top GitHub Comments
Thanks for preening the issues list! Much appreciated, it needed it
@mikehardy, can this be closed?