I am getting this error Cannot find name ‘Props’
import { ReactElement, JSXElementConstructor, ReactFragment, useState } from "react";
interface ListGroupProps{
items: string[];
heading: string;
}
function ListGroup(ListGroupProps:Props){
//items = [];
items.map(item => <li>{item}</li>)
//const message = items.length === 0 ? <h4>No items found :)</h4> : null;
const getMessage = (NoOfItems: number) => {
return items.length === 0 ? <h4>No items found :(</h4> : <h4>{NoOfItems} items found :)</h4>;
}
//Hook
const [selectedIndex, setSelectedIndex] = useState(-1);
return (<>
<h1>Header here....</h1>
{getMessage(items.length)}
<ul className="list-group">
{
items.map((item, index) => (
<li
key={item}
className={selectedIndex === index ? 'list-group-item active' : 'list-group-item'}
onClick={() => { setSelectedIndex(index) }}>
{item}
</li>
))
}
</ul>
</>);
}
export default ListGroup;