Skip to content

Commit

Permalink
Merge pull request #30962 from s-alves10/fix/issue-30935
Browse files Browse the repository at this point in the history
fix: remove wrong use of createRef
  • Loading branch information
robertjchen authored Nov 7, 2023
2 parents 096fa33 + 8a982c8 commit 73ded84
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/components/InvertedFlatList/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import PropTypes from 'prop-types';
import React, {forwardRef, useEffect, useRef} from 'react';
import {DeviceEventEmitter, FlatList} from 'react-native';
import _ from 'underscore';
import CONST from '@src/CONST';
import BaseInvertedFlatList from './BaseInvertedFlatList';

Expand All @@ -23,31 +22,24 @@ const propTypes = {
// It's a HACK alert since FlatList has inverted scrolling on web
function InvertedFlatList(props) {
const {innerRef, contentContainerStyle} = props;
const listRef = React.createRef();

const lastScrollEvent = useRef(null);
const scrollEndTimeout = useRef(null);
const updateInProgress = useRef(false);
const eventHandler = useRef(null);

useEffect(() => {
if (!_.isFunction(innerRef)) {
// eslint-disable-next-line no-param-reassign
innerRef.current = listRef.current;
} else {
innerRef(listRef);
}

return () => {
useEffect(
() => () => {
if (scrollEndTimeout.current) {
clearTimeout(scrollEndTimeout.current);
}

if (eventHandler.current) {
eventHandler.current.remove();
}
};
}, [innerRef, listRef]);
},
[innerRef],
);

/**
* Emits when the scrolling is in progress. Also,
Expand Down Expand Up @@ -113,7 +105,7 @@ function InvertedFlatList(props) {
<BaseInvertedFlatList
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
ref={listRef}
ref={innerRef}
shouldMeasureItems
contentContainerStyle={contentContainerStyle}
onScroll={handleScroll}
Expand Down

0 comments on commit 73ded84

Please sign in to comment.