Skip to content

Commit 538ec7d

Browse files
committed
fix: Use NitroWebImage directly
1 parent 76804e1 commit 538ec7d

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

example/src/NitroImageTab.tsx

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
import React, { useMemo } from "react";
2-
import { FlatList, StyleSheet, Text, View } from "react-native";
3-
import { NitroImage, useWebImage } from "react-native-nitro-image";
1+
import { useMemo } from "react";
2+
import { FlatList, Text, View } from "react-native";
3+
import { NitroWebImage } from "react-native-nitro-image";
44
import { createImageURLs } from "./createImageURLs";
55

6-
function AsyncImageImpl({ url }: { url: string }): React.ReactNode {
7-
const image = useWebImage(url);
8-
return (
9-
<NitroImage style={styles.image} image={image} resizeMode="contain" />
10-
);
11-
}
12-
const AsyncImage = React.memo(AsyncImageImpl);
13-
146
export function NitroImageTab() {
157
const imageURLs = useMemo(() => createImageURLs(), []);
168

@@ -21,15 +13,10 @@ export function NitroImageTab() {
2113
numColumns={4}
2214
windowSize={3}
2315
data={imageURLs}
24-
renderItem={({ item: url }) => <AsyncImage url={url} />}
16+
renderItem={({ item: url }) => (
17+
<NitroWebImage url={url} resizeMode="cover" />
18+
)}
2519
/>
2620
</View>
2721
);
2822
}
29-
30-
const styles = StyleSheet.create({
31-
image: {
32-
width: "25%",
33-
aspectRatio: 1,
34-
},
35-
});

0 commit comments

Comments
 (0)