🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

react-native-alphabet-slider

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-alphabet-slider

An alphabetic slider component that will move the scroll position of an alphabetically-ordered FlatList to the poisition of the letter pressed on the slider. Works similar to the contacts app on iOS.

1.0.1
latest
Source
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Alphabet Slider

An alphabetic slider component that will move the scroll position of an alphabetically-ordered FlatList to the poisition of the letter pressed on the slider.

alphabet-slider

Installation

npm i alphabet-slider-react-native

or

yarn add alphabet-slider-react-native

Usage

This package is meant to be used alongside a FlatList. The AlphabetSlider component requires 3 props to work: flatListRef, data, and path. The flatListRef is a ref passed to the FlatList component, data is the data passed to the FlatList component, and path is the path into the title of the data item.

In use it would look something like this:

import React, { useRef } from 'react';
import {View, FlatList} from 'react-native';
import AlphabetSlider from 'react-native-alphabet-slider';

const App = () => {
    const flatListRef = useRef<FlatList>(null);

    const DATA = [
        {
            id: 'bd7acbea-c1b1-46c2-aed5-3ad53abb28ba',
            title: 'First Item',
        },
        {
            id: '3ac68afc-c605-48d3-a4f8-fbd91aa97f63',
            title: 'Second Item',
        },
        {
            id: '58694a0f-3da1-471f-bd96-145571e29d72',
            title: 'Third Item',
        },
    ];

    type ItemProps = {title: string};

    const Item = ({title}: ItemProps) => (
        <View style={styles.item}>
            <Text style={styles.title}>{title}</Text>
        </View>
    );

    return (
        <View>
        <FlatList
            data={DATA}
            renderItem={({item}) => <Item title={item.title} />}
            keyExtractor={item => item.id}
            ref={flatListRef}
        />
        <FlatList flatListRef={flatListRef} data={DATA} path="title" />
        </View>
    );
};

For a working example, please take a look at the example directory.

Properties

PropDescriptionTypeDefault
flatListRefref passed to the FlatList componentstringrequired
dataThe data passed to the FlatList componentstringrequired
pathThe path into the title of the data itemnumberrequired
itemHeightThe height of the View wrapping each letternumber20
containerStyleStyles passed to the View wrapping the entire componentViewStyleundefined
alphabetItemContainerStyleStyles passed to the View wrapping each letterViewStyleundefined
alphabetItemTextStyleStyles passed to the Text component for each letterViewStyleundefined
alphabetItemTextDisabledStyleStyles passed to the Text component for each letter while disabledViewStyleundefined

Contributing

You are welcome to contribute!

License

MIT

Keywords

react native

FAQs

Package last updated on 12 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts