Skip to content

Commit

Permalink
Turn list into React ref
Browse files Browse the repository at this point in the history
  • Loading branch information
BartoszGrajdek committed Aug 28, 2023
1 parent 266ddf2 commit 67060f4
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/components/InvertedFlatList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<BaseInvertedFlatList
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
inverted
ref={(el) => (list = el)}
ref={listRef}
shouldMeasureItems
contentContainerStyle={StyleSheet.compose(contentContainerStyle, styles.justifyContentEnd)}
/>
Expand Down

0 comments on commit 67060f4

Please sign in to comment.