Im trying to use a interface on the renderItem={({ item }) from flatlist, but whenever i try im getting the same error.
"Missing return type on function. eslint(@typescript-eslint/explicit-function-return-type)"
How can i type that?
export function Notifications(): JSX.Element {
interface INotificationsProps {
id: number;
title: string;
description: string;
link: string;
}
interface INotificationsObject {
event: INotificationsProps[];
}
let datas: INotificationsObject = {
event: [
{
id: 1,
title: 'Missa de Santo Antônio',
description:
'Si osculantur puorhuus aut unexem tuam osculun, non dico qued omnia quan sunt hominiset sic non tangebur, si aut ex eis meriatur.',
link: 'www.google.com.br',
},
{
id: 2,
title: 'Bazar Beneficente',
description:
'Si osculantur puorhuus aut unexem tuam osculun, non dico qued omnia quan sunt hominiset sic non tangebur, si aut ex eis meriatur.',
link: 'www.google.com.br',
},
],
};
return (
<Fragment>
<FlatList
data={datas.event}
renderItem={({ item }) => (
<ContainerNotifications>
<TitleNotification>{item.title}</TitleNotification>
<DescriptionNotification>
{item.description}
</DescriptionNotification>
<SeeMore>Ver mais</SeeMore>
</ContainerNotifications>
)}
/>
</Fragment>
);
}
CodePudding user response:
After the argument list is where you can put the return type for the function.
({ item }): JSX.Element => (<ContainerNotifications>...)