1.0.1 • Published 4 years ago

masonry-react-native v1.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

masonry-react-native

A simple React Native implementation of Masonry layout, using ScrollView.

Features

  • allows rendering any type of content inside a View.
  • calculates each column's height and adds a new View to the smallest column, so no space will be wasted.
  • can be used with LayoutAnimation for a nicer render animation.
  • API similar with FlatList

preview

Usage

Install

Using Node Package Manager (npm):

$ npm install masonry-react-native

Import

import Masonry from 'masonry-react-native';

Render

<Masonry
	data={[
		{id: 0, text: 'Text 0'},
		{id: 1, text: 'Text 1'},
		{id: 2, text: 'Text 2'},
	]}
	numberOfColumns={3}
	keyExtractor={({id}) => id}
	renderItem={({item}) => (
		<Text>{item.text}</Text>
	)}
/>

API

PropsTypeDescriptionDefault
numberOfColumnsnumbernumber of columns2
dataarraylist of items[]
keyExtractorfuncextracts unique id
ListHeaderComponenelementelement to be rendered in the list header
renderItemfuncelement to be rendered inside the list
...restobjectthe rest of props are passed to ScrollView

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details