Skip to content

Commit

Permalink
core: let Link accept any element type as component
Browse files Browse the repository at this point in the history
  • Loading branch information
Rugvip committed Dec 10, 2020
1 parent 6349ea7 commit 2527628
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/eighty-queens-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage/core': patch
---

Link `component` prop now accepts any element type.
18 changes: 13 additions & 5 deletions packages/core/src/components/Link/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@
* limitations under the License.
*/

import React, { ComponentProps } from 'react';
import { Link as MaterialLink } from '@material-ui/core';
import { Link as RouterLink } from 'react-router-dom';
import React, { ElementType } from 'react';
import {
Link as MaterialLink,
LinkProps as MaterialLinkProps,
} from '@material-ui/core';
import {
Link as RouterLink,
LinkProps as RouterLinkProps,
} from 'react-router-dom';

type Props = ComponentProps<typeof MaterialLink> &
ComponentProps<typeof RouterLink> & { component?: React.ReactNode };
type Props = MaterialLinkProps &
RouterLinkProps & {
component?: ElementType<any>;
};

/**
* Thin wrapper on top of material-ui's Link component
Expand Down

0 comments on commit 2527628

Please sign in to comment.