ReactJS
33 строки · 669.0 Байт
1import React from 'react';
2import {noop} from "../../utils/react/noop";
3
4export interface IItem {
5itemContent: JSX.Element;
6id: string;
7onClick?: (id: string) => void;
8className?: string;
9As?: 'a' | 'li' | 'button' | 'div';
10href?: string;
11}
12
13export interface IGenericListProps {
14list: IItem[];
15}
16
17export function GenericList({list}: IGenericListProps) {
18return (
19<>
20{list.map(({As = 'div', itemContent, onClick = noop, className, href, id}) => (
21
22<As
23className={className}
24onClick={() => onClick(id)}
25key={id}
26href={href}
27>
28{itemContent}
29</As>
30))}
31</>
32);
33}
34