Skip to content

Commit

Permalink
fix prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
jkadamczyk committed Dec 27, 2023
1 parent 7dd9c54 commit 8e2fc6d
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions src/reanimated2/component/FlatList.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
'use strict';
import type { ForwardedRef } from 'react';
import React, { forwardRef } from 'react';
import type {ForwardedRef} from 'react';
import React, {forwardRef} from 'react';
import type {
FlatListProps,
LayoutChangeEvent,
StyleProp,
ViewStyle,
} from 'react-native';
import { FlatList } from 'react-native';
import { AnimatedView } from './View';
import { createAnimatedComponent } from '../../createAnimatedComponent';
import type { ILayoutAnimationBuilder } from '../layoutReanimation/animationBuilder/commonTypes';
import { LayoutAnimationConfig } from './LayoutAnimationConfig';
import type { AnimatedProps, AnimatedStyle } from '../helperTypes';
import {FlatList} from 'react-native';
import {AnimatedView} from './View';
import {createAnimatedComponent} from '../../createAnimatedComponent';
import type {ILayoutAnimationBuilder} from '../layoutReanimation/animationBuilder/commonTypes';
import {LayoutAnimationConfig} from './LayoutAnimationConfig';
import type {AnimatedProps, AnimatedStyle} from '../helperTypes';

const AnimatedFlatList = createAnimatedComponent(FlatList);

Expand Down Expand Up @@ -63,43 +63,43 @@ interface AnimatedFlatListComplement<T> extends FlatList<T> {
// We need explicit any here, because this is the exact same type that is used in React Native types
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const FlatListForwardRefRender = <ItemT = any>(props: ReanimatedFlatListPropsWithLayout<ItemT>, ref: ForwardedRef<FlatList>) => {
const { itemLayoutAnimation, skipEnteringExitingAnimations, ...restProps } =
props;
const {itemLayoutAnimation, skipEnteringExitingAnimations, ...restProps} =
props;

// Set default scrollEventThrottle, because user expects
// to have continuous scroll events and
// react-native defaults it to 50 for FlatLists.
// We set it to 1, so we have peace until
// there are 960 fps screens.
if (!('scrollEventThrottle' in restProps)) {
restProps.scrollEventThrottle = 1;
}
// Set default scrollEventThrottle, because user expects
// to have continuous scroll events and
// react-native defaults it to 50 for FlatLists.
// We set it to 1, so we have peace until
// there are 960 fps screens.
if (!('scrollEventThrottle' in restProps)) {
restProps.scrollEventThrottle = 1;
}

const CellRendererComponent = React.useMemo(
() => createCellRendererComponent(itemLayoutAnimation),
[]
);
const CellRendererComponent = React.useMemo(
() => createCellRendererComponent(itemLayoutAnimation),
[]
);

const animatedFlatList = (
// @ts-expect-error We Can't easily make the result of createAnimatedComponent generic
<AnimatedFlatList
ref={ref}
{...restProps}
CellRendererComponent={CellRendererComponent}
/>
);

if (skipEnteringExitingAnimations === undefined) {
return animatedFlatList;
}
<AnimatedFlatList
ref={ref}
{...restProps}
CellRendererComponent={CellRendererComponent}
/>
);

return (
<LayoutAnimationConfig skipEntering skipExiting>
{animatedFlatList}
</LayoutAnimationConfig>
);
if (skipEnteringExitingAnimations === undefined) {
return animatedFlatList;
}

return (
<LayoutAnimationConfig skipEntering skipExiting>
{animatedFlatList}
</LayoutAnimationConfig>
);
}

// We need explicit any here, because this is the exact same type that is used in React Native types
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const ReanimatedFlatList = forwardRef(FlatListForwardRefRender) as <ItemT = any>(props: ReanimatedFlatListPropsWithLayout<ItemT> & {
Expand Down

0 comments on commit 8e2fc6d

Please sign in to comment.