import React, { PureComponent, createElement } from 'react'; import { Button } from 'antd'; import styles from './index.less'; export interface EditableLink { title: string; href: string; id?: string; } interface EditableLinkGroupProps { onAdd: () => void; links: EditableLink[]; linkElement: React.ComponentClass; } class EditableLinkGroup extends PureComponent { static defaultProps = { links: [], onAdd: () => {}, linkElement: 'a', }; render() { const { links, linkElement, onAdd } = this.props; return (
{links.map(link => createElement( linkElement, { key: `linkGroup-item-${link.id || link.title}`, to: link.href, href: link.href, }, link.title ) )} { }
); } } export default EditableLinkGroup;