masonry-react-native

1.0.1 • Public • Published

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

Props Type Description Default
numberOfColumns number number of columns 2
data array list of items []
keyExtractor func extracts unique id
ListHeaderComponen element element to be rendered in the list header
renderItem func element to be rendered inside the list
...rest object the 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

Package Sidebar

Install

npm i masonry-react-native

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

6.84 kB

Total Files

4

Last publish

Collaborators

  • iandrew3