-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: update * feat: MasonryList react native example * feat: MasonryList react native example * feat: bump expo 0.52 * feat: lock initNumberToRender = 0 * fix: snap jump issue * fix: snpm jump issue
- Loading branch information
Showing
26 changed files
with
1,701 additions
and
2,019 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { useCallback, useMemo, useRef } from 'react'; | ||
import { List, ScrollView } from '@infinite-list/react-native'; | ||
import { | ||
// NativeScrollEvent, | ||
// NativeSyntheticEvent, | ||
Text, | ||
View, | ||
} from 'react-native'; | ||
|
||
const buildData = (count: number, startIndex = 0) => | ||
new Array(count).fill(1).map((v, index) => ({ | ||
key: index + startIndex, | ||
value: index + startIndex, | ||
})); | ||
|
||
export default () => { | ||
const data = useMemo(() => buildData(10000), []); | ||
const scrollViewRef = useRef<ScrollView>(null); | ||
|
||
const renderItem = useCallback((props: { item }) => { | ||
const { item } = props; | ||
return ( | ||
<View style={{ height: 80, width: '100%', backgroundColor: '#fff' }}> | ||
<Text>{item.value}</Text> | ||
</View> | ||
); | ||
}, []); | ||
|
||
const keyExtractor = useCallback((item) => { | ||
return item.key; | ||
}, []); | ||
|
||
return ( | ||
<ScrollView | ||
ref={scrollViewRef} | ||
// onScroll={onScroll} | ||
contentContainerStyle={{ | ||
backgroundColor: '#fff', | ||
}} | ||
> | ||
<List | ||
data={data} | ||
renderItem={renderItem} | ||
test="3" | ||
id="basic" | ||
keyExtractor={keyExtractor} | ||
containerRef={scrollViewRef} | ||
/> | ||
</ScrollView> | ||
); | ||
}; |
57 changes: 57 additions & 0 deletions
57
examples/ReactNativeListPlayground/app/(tabs)/MasonryList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { useCallback, useMemo, useRef } from 'react'; | ||
import { ScrollView as NativeScrollView } from 'react-native'; | ||
import { MasonryList, ScrollView } from '@infinite-list/react-native'; | ||
import { Text, View } from 'react-native'; | ||
|
||
const buildData = (count: number, startIndex = 0) => | ||
new Array(count).fill(1).map((v, index) => ({ | ||
key: index + startIndex, | ||
value: index + startIndex, | ||
})); | ||
|
||
export default () => { | ||
const data = useMemo(() => buildData(10000), []); | ||
const scrollViewRef = useRef<NativeScrollView>(null); | ||
|
||
const renderItem = useCallback((props: { item }) => { | ||
const { item, itemMeta } = props; | ||
const index = itemMeta.getIndexInfo().index; | ||
const totalIndex = itemMeta.getIndexInfo().indexInTotal; | ||
|
||
return ( | ||
<View | ||
style={{ | ||
height: totalIndex % 3 ? 50 : 75, | ||
flex: 1, | ||
width: '100%', | ||
backgroundColor: index % 2 ? '#fff' : '#eee', | ||
}} | ||
> | ||
<Text>{item.value}</Text> | ||
</View> | ||
); | ||
}, []); | ||
|
||
const keyExtractor = useCallback((item) => { | ||
return item.key; | ||
}, []); | ||
|
||
return ( | ||
<ScrollView | ||
ref={scrollViewRef} | ||
contentContainerStyle={{ | ||
backgroundColor: '#fff', | ||
}} | ||
> | ||
<MasonryList | ||
data={data} | ||
renderItem={renderItem} | ||
id="basic" | ||
recyclerBufferSize={100} | ||
recyclerReservedBufferPerBatch={50} | ||
keyExtractor={keyExtractor} | ||
containerRef={scrollViewRef} | ||
/> | ||
</ScrollView> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.