We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
useAsync
state.result
initialValue
None
state.result returned from useAsync with initialValue set has type Result | undefined. But JSDoc says
Result | undefined
Value that will be set on initialisation, before the async function is executed.
I'd expect useAsync handle initialValue as useState does. Look at typings:
useState
function useState<S>(initialState: S | (() => S)): [S, Dispatch<SetStateAction<S>>]; function useState<S = undefined>(): [S | undefined, Dispatch<SetStateAction<S | undefined>>];
const [{ result: initialData }] = useAsync( myAsyncFunction, [paramA], { initialValue: "RESULT", }, ); // Has type "string" | undefined initialData
initialData should have type "string"
initialData
@react-hookz/web
react
react-dom
typescript
The text was updated successfully, but these errors were encountered:
useState is way easier to type that way, but nevertheless i'll fix today
Sorry, something went wrong.
fix: improve useAsync typings
452fa19
`useAsync` return state now properly handles presence of `initialState` option. resolves #134
73b42ff
chore(release): 3.0.1 [skip ci]
6cac2e7
## [3.0.1](v3.0.0...v3.0.1) (2021-06-16) ### Bug Fixes * improve `useAsync` typings ([#135](#135)) ([73b42ff](73b42ff)), closes [#134](#134)
🎉 This issue has been resolved in version 3.0.1 🎉
The release is available on:
Your semantic-release bot 📦🚀
xobotyi
No branches or pull requests
Prior Issues
None
What is the current behavior?
state.result
returned fromuseAsync
withinitialValue
set has typeResult | undefined
. But JSDoc saysI'd expect
useAsync
handleinitialValue
asuseState
does. Look at typings:Steps to Reproduce
What is the expected behavior?
initialData
should have type "string"Environment Details
@react-hookz/web
version: 2.2.0react
version: 16.14.0react-dom
version: 16.14.0typescript
version: 4.3.2The text was updated successfully, but these errors were encountered: