Type 'ListRenderItem<IPhotos>' is not assignable to type 'ListRenderItem<unknown>

Viewed 203

why I get this error:

Type 'ListRenderItem<IPhotos>' is not assignable to type 'ListRenderItem<unknown> 

Code:

import { Dimensions, Image, ListRenderItem, Pressable, StyleSheet, Text, View } from 'react-native'
import React from 'react'
import { IImageSlider } from './Model'
import { FlatList } from 'react-native-gesture-handler'
import { IPhotos } from '../Product'
import Animated from 'react-native-reanimated'

const { width } = Dimensions.get('window');

const AnimatedFlatlist = Animated.createAnimatedComponent(FlatList);

const ImageSlider = ({ photos }: IImageSlider) => {
  const renderItem: ListRenderItem<IPhotos> = ({ item }) => {
    return (
      <Pressable>
        <Image source={{uri: item.photo}} style={s.image} resizeMode='contain' />
      </Pressable>
    )
  };
  return (
    <AnimatedFlatlist
      data={photos}
      renderItem={renderItem}
      keyExtractor={(item) => item.image_id}
      pagingEnabled
      horizontal
      style={s.flatList}
    />
  )
}

What I am doing wrong ? If I replace animated flatlist with flatlist then it works but I have to use the Animated. Can anyone help me to solve this ts error ?

1 Answers
Related