ForwardRef and Animated.FlatList not set
See original GitHub issueDescription
Should Animated.FlatList be using forwardRef like this?
const ReanimatedFlatlist = forwardRef<FlatList, ReanimatedFlatlistProps<any>>(
({ itemLayoutAnimation, ...restProps }, ref) => {
const cellRenderer = React.useMemo(() => createCellRenderer(itemLayoutAnimation), []);
return <AnimatedFlatList ref={ref} {...restProps} CellRendererComponent={cellRenderer} />;
},
);
I noticed i couldn’t use useRef
with Animated.FlatList as you get the warning about Function components cannot be given refs
I’m happy to raise a PR, do let me know
Expected behavior
can use useRef
with Animated.FlatList, particular to scroll with react navigation useScrollToTop
hook
Actual behavior & steps to reproduce
Couldn’t use useRef
with Animated.FlatList as you get the warning about Function components cannot be given refs
Package versions
name | version |
---|---|
react-native-reanimated | 2.3 |
expo | 44 |
Affected platforms
- Android
- iOS
- Web
ps Thank you for an amazing library
Issue Analytics
- State:
- Created 2 years ago
- Reactions:14
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Typescript forwardRef error in react native - Stack Overflow
To be honest, it feels weird to see the forwardRef in this context. I mean, what you really want is to have the...
Read more >Direct Manipulation - React Native
If you run this you will immediately see this error: Touchable child must either be native or forward setNativeProps to a native component...
Read more >react-native-super-grid - npm
Methods called on SectionList/FlatList refs can be called directly now (because of forwardRef). i.e Instead of ref.current.sectionList.
Read more >property 'ref' does not exist on type 'intrinsicattributes - You.com
So the main problem here is that you're returning the result of React.forwardRef in your render, which isn't a valid return type for...
Read more >Why do I get error when I use forwardRef in react-native?
const Audio = React.forwardRef((props,ref) => { return( // error is here component name must starts with a capital letter <audio src={Song} ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sure thing
Can we have this available as a patch version in next 2.9.2 version ?