[TypeScript] Paper with component=Link
See original GitHub issueI might be doing something wrong, but I cannot use component Link with Paper.
- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
Getting the following exception:
Type '(props: LinkRouter) => JSX.Element' is not assignable to type '"object" | "meter" | "textarea" | "button" | "style" | "progress" | "ruby" | "table" | "small" | "sub" | "embed" | "pre" | "caption" | "menu" | "menuitem" | "a" | "abbr" | "address" | ... 101 more ... | undefined'.
Type '(props: LinkRouter) => JSX.Element' is not assignable to type 'FunctionComponent<HTMLAttributes<HTMLElement>>'.
Types of parameters 'props' and 'props' are incompatible.
Type 'PropsWithChildren<HTMLAttributes<HTMLElement>>' is not assignable to type 'LinkRouter'.
Property 'to' is missing in type 'HTMLAttributes<HTMLElement> & { children?: ReactNode; }' but required in type 'LinkProps<PoorMansUnknown>'.
Expected Behavior 🤔
I should be able to use any component with Paper.
Steps to Reproduce 🕹
Steps:
import React from "react";
import {Link as RouterLink, LinkProps as RouterLinkProps} from "react-router-dom";
import Link, {LinkProps} from "@material-ui/core/Link";
import Paper from "@material-ui/core/Paper";
type LinkRouter = RouterLinkProps & Omit<LinkProps, "component">
const LinkRouter = (props: LinkRouter) => <Link underline="none" component={RouterLink} {...props}/>
export default () => (
<Paper component={LinkRouter} to="/page">Link</Paper>
)
It works as expected if I use Avatar
instead.
Context 🔦
I’d like to keep classes and options from paper but use a link. It works fine without TypeScript…
Your Environment 🌎
Tech | Version |
---|---|
Material-UI | v4.9.14 |
React | v16.13.1 |
Browser | Chrome |
TypeScript | 3.9.3 |
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:18 (9 by maintainers)
Top Results From Across the Web
[TypeScript] Paper with component=Link · Issue #21154 - GitHub
I'd like to keep classes and options from paper but use a link. It works fine without TypeScript... Your Environment. Tech, Version. Material ......
Read more >Material UI - TS - component prop typing - Property 'x' does not ...
I would like to pass the target property to my Paper component to reach the underlying a component. // Next.js Link component <Link...
Read more >Getting started with Angular
HTML · JavaScript · TypeScript ... Pass data to a child componentlink. Currently, the product list displays the name and description of each...
Read more >react-native-paper-select - npm
This module includes a customizable multi-select and a single select component for React Native Paper. The package is both Android and iOS ...
Read more >Documentation - JSX - TypeScript
jsx file extension. The react mode will emit React.createElement , does not need to go through a JSX transformation before use, and the...
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 FreeTop 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
Top GitHub Comments
@oliviertassinari I am picking this up
I’m encountering
With a
<Box component='form' noValidate />
Is that same underlying issue ? Or should I reopen separately ? @eps1lon @oliviertassinari
EDIT: For now, using kinda same hack