# react-native-multichoice-flatlist

> React Native Multi/Single Choice Flatlist

Latest version **1.0.9** (published 2019-06-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-native-multichoice-flatlist
pnpm add react-native-multichoice-flatlist
yarn add react-native-multichoice-flatlist
bun add react-native-multichoice-flatlist
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2019-06-26 |
| First published | 2019-06-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 18.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Sasan Ebrahimi |
| Maintainers | s-ebrahimi |
| Keywords | react-native-multichoice-flatlist, react-native-singlechoice-flatlist, multichoice-flatlist, react-native-selectable-flatlist, react-native-selectable-list, singlechoice-flatlist, react-native-flatlist, flatlist, react-native-list, react-native |

## Links

- npm: https://www.npmjs.com/package/react-native-multichoice-flatlist
- Repository: https://github.com/sasan-ebrahimi/react-native-multichoice-flatlist
- Homepage: https://github.com/sasan-ebrahimi/react-native-multichoice-flatlist#readme
- Issues: https://github.com/sasan-ebrahimi/react-native-multichoice-flatlist/issues
- npm.io page: https://npm.io/package/react-native-multichoice-flatlist

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 1.0.9 (latest) — 2019-06-26
- 1.0.8 — 2019-06-26
- 1.0.7 — 2019-06-25
- 1.0.6 — 2019-06-24
- 1.0.5 — 2019-06-24
- 1.0.4 — 2019-06-24
- 1.0.3 — 2019-06-24
- 1.0.2 — 2019-06-24
- 1.0.1 — 2019-06-24
- 1.0.0 — 2019-06-24

## README

## Multiple / Single Choice Flatlist

### Advantages :

- Completely customizable
- Supports all FlatList props
- Supports both multiple mode and single mode

## Version 1.0.9

- bug fixed

## 1. Install

    npm install --save react-native-multichoice-flatlist

## 2. Usage

    import {MultiChoiceFlatList} from "react-native-multichoice-flatlist";

    ...

    <MultiChoiceFlatList
        ref={"mc"}
        data={[
            {id: 1, title: "First Item" , anotherProp:"the other prop" },
            {id: 2, title: "Second Item" , anotherProp:"the other prop" },
            {id: 3, title: "Third Item" , anotherProp:"the other prop" },
            {id: 4, title: "Fourth Item" , anotherProp:"the other prop" },
            {id: 5, title: "Fifth Item" , anotherProp:"the other prop" },
        ]}
        renderItem={(item, index) => {
            return (
                <View>
                    <Text style={{backgroundColor:'green'}}>
                        {item.title}
                    </Text>
                </View>
            )
        }}

        renderSelectedItem={(item, index) => {
           return (
               <View>
                    <Text>
                        {item.title}
                    </Text>
                </View>
            )
        }}

        onSelectedIndexesChange={(item, index, selected) => {
            console.log("item ", item);
            console.log("index ", index);
            console.log("is selected ", selected);
        }}

        singleMode={false}
        selectedIndexes={[2,3]}
        keyExtractor={(item, index) => item.id}

    />

    ...

## Props

|Prop| Type | Default | Description |
|--|--|--|--|
| data | array  | [] | the data to be shown (as orginal flatlist) |
| renderItem | function | - | renders non selected item |
| renderSelectedItem | function | - | renders selected item |
| singleMode | boolean | true | if 'true' just one item can be selected, if 'false' it's multichoice |
| selectedIndex | int | 0 | ( ONLY WHEN 'singleMode=true' ) default selected item |
| selectedIndexes | array of int | [] | ( ONLY WHEN 'singleMode=false' ) default selected items |
| onSelectedIndexesChange | function | - | listener function for item selection which provides touched item , index of touched item, a boolean which shows if the item is selected or not |
| keyExtractor | function | - | is required for rerendering the flatlist when data changes. |

## Methods

| Method | Return Type | Description |
|--|--|--|
| getSelectedItems | array  | returns an array containing selected items |
| getNonSelectedItems | array  | returns an array containing non selected items |

## Screenshots
|Screenshots|
|--|
|![ios](http://s-ebrahimi.com/lib_images/react-native-multichoice-flatlist.png)|

---
_Source: https://npm.io/package/react-native-multichoice-flatlist · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
