

Pinterest like masonry listview made in React Native
source link: https://reactnativeexample.com/pinterest-like-masonry-listview-made-in-react-native/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

react-native-masonry-list
Pinterest like listview made in React Native. It just behaves like the FlatList so it is easy to use.
Installation
yarn add @react-native-seoul/masonry-list
import MasonryList from '@react-native-seoul/masonry-list';
For deno user (Experimental)
import RNMasonryList from "https://deno.land/x/react_native_masonry_list/index.ts";
Preview
2-columns 3-columns 4-columns


You can use as many columns as you want. It is flexible!
YouTube
Description
Current MasonryList
extends ScrollView and can pass down its props. Indeed, this looks similar to FlatList to provide good developer experience. Look how this is used and compare to the FlatList
.
The FlatList
won't offer you to draw MansonryList
because when you provide numColumns bigger than 1
, the native view will switch to FlatList
to GridView
which will render its children with identical height only.
Our MasonryList
view component is able to render all child views with all different sizes.
Props
keyPrefix?: string;
loading?: boolean;
refreshing?: RefreshControlProps['refreshing'];
onRefresh?: RefreshControlProps['onRefresh'];
onEndReached?: () => void;
onEndReachedThreshold?: number;
style?: StyleProp<ScrollViewProps>;
data: T[];
renderItem: ({item: T, i: number}) => ReactElement;
LoadingView?: React.ComponentType<any> | React.ReactElement | null;
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement | null;
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement | null;
ListFooterComponent?: React.ComponentType<any> | React.ReactElement | null;
numColumns?: number;
keyPrefix
- Add prefix for keying child views. This is currently incremented by 1
.
loading
- Currently in loading status.
refreshing
- Currently in refreshing status.
onRefresh
- Callback when refresh
has been triggered.
onEndReached
- Callback when end is reached just like the onEndReached in FlatList
style
- Style props for ScrollView which is the container view.
data
- The array of the data
for the view to render in renderItem
rednerItem
- Render custom view with the data
passed down.
LoadingView
- Custom loading view when the view is in loading
status.
ListHeaderComponent
- Header component
ListFooterComponent
- Footer component
ListEmptyComponent
- Component to render when the data
is empty.
numColumns
- Number of columns you want to render. Default to 2
.
Usage
<MasonryList
data={filteredItems}
keyExtractor={(item, index): string => index.toString()}
numColumns={2}
showsVerticalScrollIndicator={false}
renderItem={({item}) => <CardItem />}
refreshing={isLoadingNext}
onRefresh={() => refetch({first: ITEM_CNT})}
onEndReachedThreshold={0.1}
onEndReached={() => loadNext(ITEM_CNT)}
/>
Run Example
-
Clone the repository.
git clone https://github.com/hyochan/react-native-masonry-list.git
-
Navigate to example project
cd RNMasonryExample
-
Install packages and run it as you do in
react-native
project.
GitHub
Recommend
-
90
前面写了一篇文章,介绍FlexLib这个布局库,见IOS新一代界面开发利器 —— FlexLib。然后有很多网友问相比于Masonry有什么优势,今天就简单对比一下两者优劣。 Masonry是一个非常优秀的开源库,可以说是Masonry的出现拯救了Autola
-
80
-
77
-
8
react-native-masonry-list Pinterest like listview made in React Native. It just behaves like the FlatList so it is easy to use. Installation yarn add @react-native-seoul/masonry-list
-
7
Would you like to support me? react-native-masonry-grid Customizable masonry Flatlist. it just behave like Flatlist but using
-
11
-
9
Tree UI component for React Native that allows to create a listview with N levels of nesting Jan 14, 2023 3 min read
-
5
Native CSS masonry layoutPublished: 2023.02.09 · 2 minutes readA masonry type of layout, one of the biggest obsessions of UX designers, is finally coming to CSS. Style popularized by Pinterest, where elements fill the...
-
6
-
5
react-native-swipe-list-view for examples and see the migrating-to-flatlist doc for a migration guide...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK