Skip to content

Commit

Permalink
refactor: optimize renderCard function in App.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
Skipperlla committed May 12, 2024
1 parent ea3ab76 commit aab2673
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ const App = () => {
const ref = useRef<SwiperCardRefType>();

const renderCard = useCallback(
(image: ImageSourcePropType, index: number) => {
console.log('index', index);
(image: ImageSourcePropType) => {
return (
<View style={styles.renderCardContainer}>
<Image
Expand Down
26 changes: 11 additions & 15 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,17 @@ const IMAGES: ImageSourcePropType[] = [
const App = () => {
const ref = useRef<SwiperCardRefType>();

const renderCard = useCallback(
(image: ImageSourcePropType, index: number) => {
console.log('index', index);
return (
<View style={styles.renderCardContainer}>
<Image
source={image}
style={styles.renderCardImage}
resizeMode="cover"
/>
</View>
);
},
[]
);
const renderCard = useCallback((image: ImageSourcePropType) => {
return (
<View style={styles.renderCardContainer}>
<Image
source={image}
style={styles.renderCardImage}
resizeMode="cover"
/>
</View>
);
}, []);
const OverlayLabelRight = useCallback(() => {
return (
<View
Expand Down

0 comments on commit aab2673

Please sign in to comment.