[Link] typescript error Property 'component' does not exist on type IntrinsicAttributes ...
See original GitHub issueLink does not accept component property on some cases
- This is not a v0.x issue.
- I have searched the issues of this repository and believe that this is not a duplicate.
I’ve looked #14970 #15827 but didn’t find the solution
Expected Behavior 🤔
<Link component={MyComponent} />
should compile with no error
Current Behavior 😯
In some cases(required props not supplied), typescript reports error Property 'component' does not exist on type IntrinsicAttributes & AnchorHTMLAttributes<HTMLAnchorElement> ...
Steps to Reproduce 🕹
Link: codesandbox
- Open
demo.tsx - Sees 3 compilation errors
Code:
import React, { ReactNode } from "react";
import { makeStyles } from "@material-ui/core/styles";
import Link, { LinkProps } from "@material-ui/core/Link";
import { Link as RouterLink } from "react-navi";
const useStyles = makeStyles(theme => ({
link: {
marginRight: theme.spacing(1),
cursor: "pointer"
}
}));
interface Props {
to: string;
children: ReactNode;
}
function SimpleLink(props: Props) {
const { to, children, ...restProps } = props;
return (
<a {...restProps} href={to}>
{children}
</a>
);
}
function IconLink(props: LinkProps) {
return (
<Link {...props} component={RouterLink}>
!SomeIcon
</Link>
);
}
export default function ButtonRouter() {
const classes = useStyles();
return (
<>
<Link className={classes.link}>Plain</Link>
<Link className={classes.link} component={SimpleLink}>
!Simple
</Link>
<Link
className={classes.link}
to="https://github.com"
component={SimpleLink}
>
Simple
</Link>
<Link className={classes.link} component={RouterLink}>
!Navi Router
</Link>
<Link
className={classes.link}
href="https://frontarm.com/navi"
component={RouterLink}
>
Navi Router
</Link>
<IconLink />
</>
);
}
Context 🔦
Wrap Link component to provide custom tooltip, styles etc.
Your Environment 🌎
| Tech | Version |
|---|---|
| Material-UI | ^4.2.1 |
| React | 16.8.6 |
| Browser | Chrome |
| TypeScript | 3.5.3 |
Issue Analytics
- State:
- Created 4 years ago
- Reactions:31
- Comments:22 (1 by maintainers)
Top Results From Across the Web
[Link] typescript error Property 'component' does not exist on ...
In some cases(required props not supplied), typescript reports error Property 'component' does not exist on type IntrinsicAttributes ...
Read more >react router - Property 'component' does not exist on type
Why do I get this error for the when to declare a "component" property in "Route"; Property 'component' does not exist on type...
Read more >Typescript Property XXX does not exist on type ... - Edureka
The exact error that I'm getting: TS2339: Property 'propToPass' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component ...
Read more >property '' does not exist on type 'intrinsicattributes' - You.com
It looks (to my relatively new React eyes) like Connect was not supplying an explicit interface to the container component, so it was...
Read more >Useful Patterns by Use Case - React TypeScript Cheatsheets
Usecase: same as above, but for a React Component you don't have access to the ... {/* Error: Property 'toPrecision' does not exist...
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

Anyone else think the best solution might be just to not use Typescript?!
What is the status of this??? It does not seem like there’s a fix for this or some solution that helps us solve the issue.
Custom Button
Usage
Error