Skip to content

sahilbakoru/react-native-option-dropdown

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

react-native-option-dropdown is light dropdown for simple react native apps. (< 5 KB)

Demo 1

Getting started

npm i react-native-option-dropdown

MacOS

MacOS needs this extra step (called from the MacOS directory)

pod install 

Usage

Import Dropdown from react-native-option-dropdown':

import Dropdown from 'react-native-option-dropdown';

Create state which will be used by the Dropdown:

    const [selectedItem, setSelectedItem] = useState(null);

Add Dropdown like this:

import { StyleSheet, Text, View } from 'react-native'
import React, {useState} from 'react';
import Dropdown from 'react-native-option-dropdown'

const App = () => {
    const [selectedItem, setSelectedItem] = useState(null);

    let data = [
        {id: 1, name: 'All'},
        {id: 2, name: 'Today'},
        {id: 3, name: 'Yesterday'},
        {id: 4, name: 'Current Week'},
      ];

      const onSelect = item=>{
        setSelectedItem(item);
        alert(item.name)
      } 
  return (
    <View style={{marginTop:'10%'}}>
           <Dropdown
          data={data}
          onSelect={onSelect}
          value={selectedItem}
        />
    </View>
  )
}

export default App


Suggestions and feedback are welcome at sahilbakoru1999@gmail.com .