React native snippet. FlatList Grid

This react native snippet, FlatList Grid, was created to help android and ios developers save time
while they build native mobile apps using JavaScript and React
use it in your project and build your app faster

React native code

Copy, paste and run the following code to get a result like the one shown in the image

import React from 'react';
import { 
} from 'react-native';

export default class App extends React.Component {

  constructor(props) {
    this.state = {
      data: [
        { key: 'A' }, { key: 'B' }, { key: 'C' }, { key: 'D' }, { key: 'E' }, { key: 'F' }, { key: 'G' }, { key: 'H' }, { key: 'I' }, { key: 'J' },

  renderItem = ({item, index}) => {
    if (item.empty === true) {
      return <View style={[styles.item, styles.itemInvisible]} />;
    return (
      <View style={[styles.item, {height: Dimensions.get('window').width / this.state.numColumns}]}>
        <Text style={styles.itemText}>{item.key}</Text>
  formatRow = (data, numColumns) => {
    const numberOfFullRows = Math.floor(data.length / numColumns);
    let numberOfElementsLastRow = data.length - (numberOfFullRows * numColumns);
    while (numberOfElementsLastRow !== numColumns && numberOfElementsLastRow !== 0) {
      data.push({ key: `blank-${numberOfElementsLastRow}`, empty: true });
    return data;

  render() {
    return (
        data={this.formatRow(, this.state.numColumns)}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    marginVertical: 20,
  item: {
    backgroundColor: '#6495ED',
    alignItems: 'center',
    justifyContent: 'center',
    flex: 1,
    margin: 1,
  itemInvisible: {
    backgroundColor: 'transparent',
  itemText: {
    color: '#fff',

About this react-native snippet

This react-native snippet, FlatList Grid, was published on Dec 27th 2018, 10:23 by Dey Dey and it is free.

We hope you will enjoy this awesome react-native snippet and stay tuned for the latest updates, we believe it will save your precious time and gives trendy look to your next application.

This snippet currectly have 4.3K views, Using this react-native snippet you have the following benefits:

Example Screens

You can jump start your development with our pre-built example, all you need to do is copy the code and execute it, You can also show it to your customers so that they have an idea of the final project.

Cross-platform for mobile development

This snippet was developed for Android and iOS.

Simple Integration

This snippet can be simply integrated on existing projects and new ones too, all you need to do is copy the code and start working.

Fully coded view

this is a functional example, You will save a lot of time going from prototyping to full-functional code.