software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
8.83k stars 1.29k forks source link

CellRendererComponent prop does not work with Animated.Flatlist #5931

Closed regalstreak closed 4 months ago

regalstreak commented 4 months ago

Description

CellRendererComponent prop does not work with Animated.Flatlist

Steps to reproduce

Use a Animated.FlatList

Put in a CellRendererComponent prop

It wouldn't render on Android

Snack or a link to a repository

https://snack.expo.dev/wI0E5xWM3_QzmQbwRYnwV

Reanimated version

3.8.1

React Native version

0.73

Platforms

Android, iOS

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

hirbod commented 4 months ago

This is expected:

https://github.com/software-mansion/react-native-reanimated/blob/f5dfead408701d3175512c3c6a5f6f8ab349ff59/src/reanimated2/component/FlatList.tsx#L95

You could copy the implementation and adapt it to your needs instead of using Animated.FlastList.

Latropos commented 4 months ago

Yes, this is an expected behaviour. I can confirm that @hirbod suggestions above are very reliable and you can follow them to customise CellRendererComponent according to your needs

el-banna commented 4 months ago

I would really recommend thinking of a way to provide styles to each item's wrapper view. A very common use case of CellRendererComponent is to set the zIndex of the items.

Copying the implementation of Animated.FlatList is kinda an overkill to achieve that. It also prevents us from getting any bug fixes that will be pushed for Animated.FlatList in the future.