1.0.4 • Published 3 years ago

react-native-section-list-grid v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

SectionListGrid

We have a list component in react native, but we have a section list component in react native as well, but we don't have a component for section grid list view. It helps to easily create a grid list view with your own style and customize the view.

Attachments

ScreenshotScreenshotScreenshot

Installation

yarn add react-native-section-list-grid

or

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

Example

Code

import React from 'react';
import { View, Text } from 'react-native';
import SectionListGrid from 'react-native-section-list-grid';

export default ExampleOne = () => {
    const data = [
        {
            title: "Main dishes",
            data: ["Pizza", "Burger", "Risotto"]
        },
        {
            title: "Sides",
            data: ["French Fries", "Onion Rings", "Fried Shrimps"]
        },
        {
            title: "Drinks",
            data: ["Water", "Coke", "Beer"]
        },
        {
            title: "Desserts",
            data: ["Cheese Cake", "Ice Cream"]
        }
    ];

    return (
        <View style={{ marginTop: 50 }}>
            <SectionListGrid
                data={data}
                numItemsRow={2}
                renderItem={(subObj, subIndex) => {
                    <Text style={{ margin: 5, backgroundColor: 'grey' }} key={subIndex}>
                        {subObj}</Text>
                }}
                renderHeader={(obj, index) => {
                    <Text style={{ margin: 5, backgroundColor: 'green' }}>
                        {obj.title}</Text>
                }}
            />
        </View>
    );
};

Check the code here

Props

PropDefaultTypeDescription
data[] requiredarrayData to use in renderSectionList
numItemsRow3numbernumber of item per row
itemViewStyle{}ViewPropTypesstyle of grid item view
listStyle{}ViewPropTypesstyle of entire listview
cellStyle{}ViewPropTypesstyle of one section view
headerStyle{}TextPropTypesstyle of section header text
renderItem{}rendercreate own grid cell view
renderHeader{}rendercreate own section header view

Author

Loganathan Rajamani