From 67060f4bb45c73b5287a8624924b5eb3d8c86bad Mon Sep 17 00:00:00 2001 From: Bartosz Grajdek Date: Mon, 28 Aug 2023 11:39:42 +0200 Subject: [PATCH] Turn list into React ref --- src/components/InvertedFlatList/index.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/components/InvertedFlatList/index.js b/src/components/InvertedFlatList/index.js index 4cd15ba60521..e8e546385207 100644 --- a/src/components/InvertedFlatList/index.js +++ b/src/components/InvertedFlatList/index.js @@ -20,24 +20,23 @@ const propTypes = { // It's a HACK alert since FlatList has inverted scrolling on web function InvertedFlatList(props) { const {innerRef, contentContainerStyle} = props; - let list; + const listRef = React.createRef(); useEffect(() => { if (!_.isFunction(innerRef)) { // eslint-disable-next-line no-param-reassign - innerRef.current = list; + innerRef.current = listRef.current; } else { - innerRef(list); + innerRef(listRef); } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + }, [innerRef, listRef]); return ( (list = el)} + ref={listRef} shouldMeasureItems contentContainerStyle={StyleSheet.compose(contentContainerStyle, styles.justifyContentEnd)} />