question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeScript defs for Helper Functions with Hooks

See original GitHub issue

The 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:closed
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ghengeveldcommented, Aug 7, 2019

Yes, it uses relative-deps for the examples and Yarn workspaces with Lerna for the packages. The general process is to run yarn bootstrap after the first install. Should be smooth sailing from there. Sometimes Yarn messes things up and you need to do yarn clean && yarn bootstrap to clear it up.

Don’t use yarn link on examples, it won’t work due to the way packages are built (with multiple compilation targets).

1reaction
eddiewangcommented, Aug 7, 2019

Thanks, I haven’t heard of relative-deps before, 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found