• Stars
    star
    104
  • Rank 330,604 (Top 7 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created about 7 years ago
  • Updated about 3 years ago

Reviews

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

Repository Details

🌁 Grid list component implemented with FlatList

🌁 Grid list component

platforms npm npm travis license

Demo

Installation

yarn add react-native-grid-list

or

npm install react-native-grid-list --save

Example

Expo

Example

Code

import React, { PureComponent } from 'react';
import { View, StyleSheet, Image } from 'react-native';

import GridList from 'react-native-grid-list';

const items = [
  { thumbnail: { uri: 'https://lorempixel.com/200/200/animals' } },
  { thumbnail: { uri: 'https://lorempixel.com/200/200/city' } },
  { thumbnail: { uri: 'https://lorempixel.com/200/200/nature' } },
  { thumbnail: { uri: 'https://lorempixel.com/200/200/cats' } },
];

export default class App extends PureComponent {
  renderItem = ({ item, index }) => (
    <Image style={styles.image} source={item.thumbnail} />
  );

  render() {
    return (
      <View style={styles.container}>
        <GridList
          showSeparator
          data={items}
          numColumns={3}
          renderItem={this.renderItem}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: 'white',
  },
  image: {
    width: '100%',
    height: '100%',
    borderRadius: 10,
  },
});

Check the code here

You can use all the props from FlatList: http://facebook.github.io/react-native/docs/flatlist.html

Props

Prop Default Type Description
children - node Children elements
data not required if children is used array Data to use in renderItem
renderItem not required if children is used func Function that render each item of the grid
numColumns 3 number Number of elements in a row
itemStyle {} ViewPropTypes Style for the wrapper of item
Separator
showSeparator false bool Show a separator between items
separatorBorderWidth 0 number Set separator width
separatorBorderColor 'white' string Set separator color
Animation
showAnimation false bool Show an animation when load item
animationInitialBackgroundColor 'white' string Set initial backgroundColor for animation
animationDuration 500 number Duration of the animation

Author

Gustavo Gard

More Repositories

1

react-native-swiper-flatlist

πŸ‘† Swiper component implemented with FlatList using Hooks & Typescript + strict automation tests with Detox
TypeScript
536
star
2

react-native-devsettings

Enable react-native-debugger and chrome debugger on Hermes
TypeScript
99
star
3

angular-seed-es6

🍯 Started project for AngularJS 1.5 apps using best practices + ES6 + SASS + angular material + Browserify + BrowserSync
JavaScript
16
star
4

add-stars

⭐ Add stars to all the repos in GitHub used in package.json
JavaScript
12
star
5

react-native-expo-storybook

Expo and Storybook example πŸ“–
JavaScript
10
star
6

react-native-graphql-example

πŸ₯€ A react-native project with graphql configured, snapshots and good practices
JavaScript
10
star
7

d3-bubble-matrix

A bubble matrix using d3
JavaScript
8
star
8

viro-AR-playground

πŸ–ΌοΈ Testing Viro AR and RN
JavaScript
6
star
9

ci-dashboard

JavaScript
5
star
10

api-rest-express-bookshelf

A structure to build API REST with Express and Bookshelf using NodeJS 6.
JavaScript
2
star
11

electron-workshop

An electron workshop from JSConf
JavaScript
2
star
12

gusgard.com

Static page
HTML
2
star
13

detox-cucumber-travisci

Example of Detox & Cucumber on TravisCI
JavaScript
2
star
14

angularattack2016-rimor-api

API
1
star
15

edificios

...
CSS
1
star
16

my-urls

1
star
17

bower-d3-bubble-matrix

A bubble matrix using d3
JavaScript
1
star
18

pixi-example

JavaScript
1
star
19

mongoDB

Python-django mongoDB
JavaScript
1
star
20

react-native-density

1
star
21

react-navigation-issue

https://github.com/react-navigation/react-navigation/pull/2101/
JavaScript
1
star