import {FlatList} from 'react-native';
import {SampleJoke} from "../model/SampleJoke";
import {CustomJoke} from "../model/CustomJoke";
import JokeItem from "./JokeItem";

type JokeListItemProps = {
    jokes: (CustomJoke | SampleJoke)[];
};

export default function JokeItems(props: JokeListItemProps) {
    return (
        <FlatList
            data={props.jokes}
            keyExtractor={(item) => item.id.toString()}
            renderItem={
                ({ item }: { item: CustomJoke | SampleJoke }) => (
                    <JokeItem joke={item}/>
                )
            }
        />
    );
}