TypeScript defs for Helper Functions with Hooks
See original GitHub issueThe README shows a declarative approach to writing hook-based react-async resolvers. However, if implemented with Typescript, the following error appears:
const Rejected: <T>(props: {
children?: AsyncChildren<T>;
persist?: boolean;
}) => JSX.Element
Type '{ children: (error: AsyncState<unknown>) => Element; state: AsyncState<StandardResp<CoinProfileResp>>; }' is not assignable to type 'IntrinsicAttributes & { children?: AsyncChildren<unknown>; persist?: boolean; }'.
Property 'state' does not exist on type 'IntrinsicAttributes & { children?: AsyncChildren<unknown>; persist?: boolean; }'.
Going into the definitions, it seems like state isn’t considered a prop that is passed through. The same goes for Pending and Fufilled components.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Working With React Hooks and TypeScript - Toptal
This article will introduce you to hooks in React and demonstrate how you can harness the potential of hooks in a code-complete tutorial....
Read more >Invalid Hook Call when calling a helper function with ...
I'm using the function renderBatches that calls this helper function inside a FlatList renderItem. I tried searching for alternatives and found ...
Read more >useTypescript — A Complete Guide to React Hooks and ...
React v16.8 introduced Hooks which provide the ability to extract state and the React lifecycle into functions that can be utilized across ...
Read more >Hooks - React TypeScript Cheatsheets
Hooks are supported in @types/react from v16.8 up. ... You can type the useCallback just like any other function. const memoizedCallback = useCallback(...
Read more >Adding types to native React Hooks. All about including ...
We won't define Types for combineReducers() function or Loading component, as they are just middleware helpers, but you can try it on your...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yes, it uses
relative-depsfor the examples and Yarn workspaces with Lerna for the packages. The general process is to runyarn bootstrapafter the first install. Should be smooth sailing from there. Sometimes Yarn messes things up and you need to doyarn clean && yarn bootstrapto clear it up.Don’t use
yarn linkon examples, it won’t work due to the way packages are built (with multiple compilation targets).Thanks, I haven’t heard of
relative-depsbefore, so I’ll try that. I need to start looking for Lerna and Yarn workspaces… both are seemingly getting very common these days!I have to say, using React Async has been an eye-opener for me. Async calls in React always felt like too much boilerplate, no matter which solution. This library is refreshingly flexible and seemingly future-proof! Kudos.