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

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 ?



Solution 1:[1]

This is not an error, its just an issue with types react-native-reanimated. Make sure you have the correct version of @types/react-native.

You can find more info on this issue below. https://github.com/software-mansion/react-native-reanimated/issues/719

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dewashish