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: Support `use` component prop types on the base component

See original GitHub issue

At the moment, if we try to compose two components via the use prop. The component specified via use will not spread its TS types on the root component. Thus, the following will produce a typescript error on the href prop:

<Button use={Link} href="https://example.com">Go to Example</Button>

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jxomcommented, Dec 6, 2020

@jxom Happy to take a crack at this if you’d like?

Go for it

1reaction
hcharleycommented, Aug 9, 2020

Yeah, I just put together my own work-around:

            <TopNav.Item
              use={RRNavLink as typeof RRNavLink & { useProps: any }}
              {...{ to: '/' }}
              fontWeight="semibold"
              paddingX="major-1"
            >

Instead of:

            <TopNav.Item
              use={RRNavLink}
              to="/"
              fontWeight="semibold"
              paddingX="major-1"
            >
Read more comments on GitHub >

github_iconTop Results From Across the Web

Typechecking With PropTypes - React
PropTypes exports a range of validators that can be used to make sure the data you receive is valid. In this example, we're...
Read more >
Typing Component Props - React TypeScript Cheatsheets
Basic Prop Types Examples​. A list of TypeScript types you will likely use in a React+TypeScript app: type AppProps = { message: string;...
Read more >
Typescript React: Access component property types
Show activity on this post. here we have to declare types for component props and state (in type variables). After we declared that...
Read more >
Build strongly typed polymorphic components with React and ...
Learn how to build strongly typed polymorphic React components with TypeScript, using familiar Chakra UI and MUI component props as guides.
Read more >
propTypes vs typescript types in React components - Medium
Supports only a limited set of types and sometimes writing a complex type can be hard with prop types and you might need...
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