@@ -103,31 +103,33 @@ Now implement **renderItem** props function **renderFlatlistItem()** like below.
103
103
104
104
Here is the ** full code** that I implemented.
105
105
106
- function renderFlatlistItem({ item }) {
107
- return (
108
- <View>
109
- <Image
110
- style={styles.image}
111
- resizeMethod="resize"
112
- source={{
113
- uri: item.url
114
- }}
115
- />
116
- <Text>{item.nftName}</Text>
117
- </View>
118
- )
119
- }
120
-
121
- // JSX code
106
+ ``` javascript
107
+ function renderFlatlistItem ({ item }) {
122
108
return (
123
- <FlashList
124
- data={myNftsData.findMyNfts}
125
- renderItem={renderFlatlistItem}
126
- estimatedItemSize={20}
127
- keyExtractor={(item) => item._id}
128
- numColumns={2}
129
- />
109
+ < View>
110
+ < Image
111
+ style= {styles .image }
112
+ resizeMethod= " resize"
113
+ source= {{
114
+ uri: item .url
115
+ }}
116
+ / >
117
+ < Text > {item .nftName }< / Text >
118
+ < / View>
130
119
)
120
+ }
121
+
122
+ // JSX code
123
+ return (
124
+ < FlashList
125
+ data= {myNftsData .findMyNfts }
126
+ renderItem= {renderFlatlistItem}
127
+ estimatedItemSize= {20 }
128
+ keyExtractor= {(item ) => item ._id }
129
+ numColumns= {2 }
130
+ / >
131
+ )
132
+ ```
131
133
132
134
Output of the Basic ** FlashList** implementation (** IOS** + ** Android** ) in my App.
133
135
@@ -265,14 +267,16 @@ For, **150 (Image) items** it gave me — **202 milliseconds** like below **(Pre
265
267
266
268
Here is the final code
267
269
268
- const MyComponent = () => {
269
- const onLoadListener = useCallback(({ elapsedTimeInMs } ) => {
270
- ingestData("Sample List load time", elapsedTimeInMs);
271
- }, []);
270
+ ``` javascript
271
+ const MyComponent = () => {
272
+ const onLoadListener = useCallback (({ elapsedTimeInMs } ) => {
273
+ ingestData (" Sample List load time" , elapsedTimeInMs);
274
+ }, []);
272
275
273
- // JSX code
274
- return <FlashList {...props} onLoad={onLoadListener} />;
275
- }
276
+ // JSX code
277
+ return < FlashList {... props} onLoad= {onLoadListener} / > ;
278
+ }
279
+ ```
276
280
277
281
## Check how much “Blank Space” raised
278
282
@@ -316,32 +320,34 @@ For a **150 items** rendering in an android simulator, these values seem to be q
316
320
317
321
Here is the full code that i implemented. So that you can just copy & test the juice 💁♂️
318
322
319
- import React, { useRef } from 'react'
320
- import { FlashList, useBlankAreaTracker } from '@shopify/flash-list'
321
-
322
- function MyListComponent(){
323
- // For FlashList
324
- const ref = useRef(null)
325
- const [blankAreaTrackerResult, onBlankArea] = useBlankAreaTracker(ref)
326
-
327
- // Only when the component will unmount then you will see the output
328
- // As we set the console in cleanUp function 👇
329
- // It will show you then the latest output of Blank Area when unmount
330
- useEffect(() => {
331
- return () => {
332
- console.log('On blank area: ', blankAreaTrackerResult)
333
- }
334
- }, [])
335
-
336
- // JSX code
337
- return (
338
- <FlashList
339
- {...props}
340
- ref={ref}
341
- onBlankArea={onBlankArea}
342
- />
343
- )
344
- }
323
+ ``` javascript
324
+ import React , { useRef } from ' react'
325
+ import { FlashList , useBlankAreaTracker } from ' @shopify/flash-list'
326
+
327
+ function MyListComponent (){
328
+ // For FlashList
329
+ const ref = useRef (null )
330
+ const [blankAreaTrackerResult , onBlankArea ] = useBlankAreaTracker (ref)
331
+
332
+ // Only when the component will unmount then you will see the output
333
+ // As we set the console in cleanUp function 👇
334
+ // It will show you then the latest output of Blank Area when unmount
335
+ useEffect (() => {
336
+ return () => {
337
+ console .log (' On blank area: ' , blankAreaTrackerResult)
338
+ }
339
+ }, [])
340
+
341
+ // JSX code
342
+ return (
343
+ < FlashList
344
+ {... props}
345
+ ref= {ref}
346
+ onBlankArea= {onBlankArea}
347
+ / >
348
+ )
349
+ }
350
+ ```
345
351
346
352
## How to reduce “Blank Space” in FlashList?
347
353
0 commit comments