Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/components/DraggableList/index.android.tsx

@ikevin127 ikevin127 May 3, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && .

Given the above checkbox has to be checked on both our checklists, I noticed that you're checking ListFooterComponent directly which is typed as React.ReactElement and this can be problematic if say a string is passed.

We should make sure that we're evaluating a boolean, and for this I suggest React.isValidElement to wrap ListFooterComponent which checks whether a value is a React element -> returning a boolean.

You can apply this to the styles check too!

Note: Make sure to run prettier once you're done with the modifications.

cc @suneox

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ListFooterComponent has type is React.ReactElement | undefinded so string or number can't match with this type so I'm also updated

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import {View} from 'react-native';
import DraggableFlatList from 'react-native-draggable-flatlist';
import type {FlatList} from 'react-native-gesture-handler';
import useThemeStyles from '@hooks/useThemeStyles';
import type {DraggableListProps} from './types';

function DraggableList<T>({renderClone, shouldUsePortal, ListFooterComponent, ...viewProps}: DraggableListProps<T>, ref: React.ForwardedRef<FlatList<T>>) {
const styles = useThemeStyles();
return (
<View style={styles.flex1}>
<DraggableFlatList
ref={ref}
containerStyle={ListFooterComponent ? undefined : styles.flex1}
contentContainerStyle={ListFooterComponent ? undefined : styles.flexGrow1}
// eslint-disable-next-line react/jsx-props-no-spreading
{...viewProps}
/>
{React.isValidElement(ListFooterComponent) && <View style={styles.flexGrow1}>{ListFooterComponent}</View>}
</View>
);
}

DraggableList.displayName = 'DraggableList';

export default React.forwardRef(DraggableList);
11 changes: 11 additions & 0 deletions src/components/MapView/responder/index.android.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {PanResponder} from 'react-native';

const InterceptPanResponderCapture = PanResponder.create({
onStartShouldSetPanResponder: () => true,
onStartShouldSetPanResponderCapture: () => true,
onMoveShouldSetPanResponder: () => true,
onMoveShouldSetPanResponderCapture: () => true,
onPanResponderTerminationRequest: () => false,
});

export default InterceptPanResponderCapture;