• Stars
    star
    308
  • Rank 135,712 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The Masonry List implementation which has similar implementation as the `FlatList` in React Native

react-native-masonry-list

Pinterest like listview made in React Native. It just behaves like the FlatList so it is easy to use.

Npm Version Downloads CI codecov code style: prettier LICENSE PRs Welcome supports iOS supports Android supports web runs with expo

Notice

If you want react-native-reanimated version, you may checkout reanimated-masonry-list. This repo is created with issue #14.

Installation

yarn add @react-native-seoul/masonry-list
import MasonryList from '@react-native-seoul/masonry-list';

Preview

2-columns 3-columns 4-columns

You can use as many columns as you want. It is flexible!

YouTube

See how to use it

Blog

How it is made

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

innerRef?: MutableRefObject<ScrollView | undefined>;
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;
keyExtractor?: ((item: T | any, index: number) => string) | undefined;

innerRef - Expose ScrollView instance with ref, example usage: ref.current.scrollTo.

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

renderItem - 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): string => item.id}
  numColumns={2}
  showsVerticalScrollIndicator={false}
  renderItem={({item}) => <CardItem />}
  refreshing={isLoadingNext}
  onRefresh={() => refetch({first: ITEM_CNT})}
  onEndReachedThreshold={0.1}
  onEndReached={() => loadNext(ITEM_CNT)}
/>

Run Example

  1. Clone the repository.

    git clone https://github.com/hyochan/react-native-masonry-list.git
    
  2. Navigate to example project

    cd RNMasonryExample
    
  3. Install packages and run it as you do in react-native project.

LICENSE

FOSSA Status

More Repositories

1

react-native-audio-recorder-player

react-native native module for audio recorder and player.
TypeScript
554
star
2

dooboo-ui-legacy

React Native UI Components with react-hook (web, ios, android)
TypeScript
143
star
3

dooboo-native-ts

Complete boilerplate for react-native app. Contains, typescript, react-hook, context-api, ts-jest, localization, navigation and etc.
TypeScript
81
star
4

react-native-drop-down-item

Dropdown list item for react-native.
JavaScript
51
star
5

DoobooIAP

Aims for feature set examples of react-native-iap
TypeScript
45
star
6

react-native-training

React Native Tutorials
JavaScript
40
star
7

reanimated-masonry-list

Masonry List with Reanimated2 component
TypeScript
40
star
8

react-navigation-sample

Examples for react-navigation v5 apis
TypeScript
34
star
9

BooKooX

The social ledger app
Dart
34
star
10

talktalk-rn

(Deprecated via hackatalk-mobile) talktalk app built in react-native.
TypeScript
30
star
11

hackatalk-server

HackaTalk backend server
TypeScript
23
star
12

Hygiene

Universal app (ios, android, web) built in expo. Individual contribution to Covid-19 Pandemic.
TypeScript
21
star
13

ts-apollo-sequelize

Graphql apollo typescript example
TypeScript
19
star
14

expo-relay-boilerplate

Relay hooks integration with expo-web
TypeScript
18
star
15

talktalk-node

(Deprecated via hackatalk-server) Graphql node project using prisma for talktalk.
TypeScript
16
star
16

style-guide

The coding guildlines for React and React Native
15
star
17

github-stats

Github readme stats in multi angles.
TypeScript
10
star
18

talktalk-flutter

Chat App with Flutter.
Dart
9
star
19

TodoMagic

Simple todo app built in SwiftUI and Jetpack Compose
Swift
9
star
20

react-native-typescript-starter

Starter project for react native and typescript.
TypeScript
8
star
21

flat_list

Flutter's [FlatList] widget for React Native friendly developers
Dart
8
star
22

relay-expo-workshop

Relay integration with expo and typescript and all its usage
TypeScript
7
star
23

WeHack

Opensource Hackathon in 2021!
Dart
7
star
24

react-navigation-v3-example

React Navigation v3 example.
JavaScript
6
star
25

starter-rn

RNProject
JavaScript
6
star
26

react-native-shorts-example

Youtube shorts example with react-native
Java
6
star
27

hyochan

5
star
28

react-redux-ts-styled-boilerplate

react web boilerplate with redux and typescript.
TypeScript
5
star
29

react-typescript-vite

React boilerplate with typescript and vite
TypeScript
4
star
30

dooboo.dev

Community tools for dooboolab
TypeScript
4
star
31

react-native-fbt

React Native FBT
Java
4
star
32

starter-expo

starter for expo project which is smiliar to starter-rn
JavaScript
3
star
33

expo-router-boilerplate

Expo typescript starter with expo router
TypeScript
3
star
34

hackatalk-website

HackaTalk website
TypeScript
3
star
35

legacy.dooboolab.com

dooboolab.com react responsive webpage.
TypeScript
3
star
36

flutter_navigation_sample

Flutter navigation sample in 2023
C++
2
star
37

hyochan.dev

Who am I
HTML
2
star
38

nvim

My nvim config
Vim Script
2
star
39

ts-node-koa-example

Typescript koa node example project.
TypeScript
2
star
40

kakao_login_android

Android sample project for kakao login.
Java
2
star
41

project-express-angular1

My first angular1 project with express server. Generally implemented sns functionalities.
JavaScript
1
star
42

dooboo.org

Documentation for dooboo
TypeScript
1
star
43

youtube_iframe

HTML
1
star
44

react-native-mobx-example

Simple react-native-mobx-example project.
JavaScript
1
star
45

flutter_boilerplate

Flutter boilerplate for embedding V2
Dart
1
star