• Stars
    star
    658
  • Rank 68,502 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This is simple implementation of drop down menu

React Native Dropdown

Simple DropDown menu for React Native App!

Introduction

React Native Dropdown is simple, customizable and easy to use dropdown in React Native. Works with both Android and IOS.

Installation

npm i react-native-dropdown --save

Usage

Require it inside your Javascript files. Also supporting components using object-deconstructing. Select Option OptionList, Also a positioning utility method updatePosition.

updatePosition should be called in componentDidMount with refs to the <Select /> component and <OptionList />.

This calculates component's PositionX and PositionY and sets it back into the component. The component uses it to position the <OptionList> using this co-ordinates.

Example

var React = require('react-native');
var {
  Component,
  AppRegistry,
  Text,
  View,
} = React;

const DropDown = require('react-native-dropdown');
const {
  Select,
  Option,
  OptionList,
  updatePosition
} = DropDown;

class App extends Component {
  constructor(props) {
    super(props);

    this.state = {
      canada: ''
    };
  }

  componentDidMount() {
    updatePosition(this.refs['SELECT1']);
    updatePosition(this.refs['OPTIONLIST']);
  }

  _getOptionList() {
    return this.refs['OPTIONLIST'];
  }

  
  _canada(province) {

	this.setState({
      ...this.state,
      canada: province
    });
  }

  render() {
    return (
      <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
          <Select
            width={250}
            ref="SELECT1"
            optionListRef={this._getOptionList.bind(this)}
            defaultValue="Select a Province in Canada ..."
            onSelect={this._canada.bind(this)}>
            <Option>Alberta</Option>
            <Option>British Columbia</Option>
            <Option>Manitoba</Option>
            <Option>New Brunswick</Option>
            <Option>Newfoundland and Labrador</Option>
            <Option>Northwest Territories</Option>
            <Option>Nova Scotia</Option>
            <Option>Nunavut</Option>
            <Option>Ontario</Option>
            <Option>Prince Edward Island</Option>
            <Option>Quebec</Option>
            <Option>Saskatchewan</Option>
            <Option>Yukon</Option>
          </Select>

          <Text>Selected province of Canada: {this.state.canada}</Text>
          
          <OptionList ref="OPTIONLIST"/>
      </View>
    );
  }
}

AppRegistry.registerComponent('App', () => App);

For complete implementation checkout example folder.

Configuration

Select:
Property Type Default Description
width number 400 Width of the selection
height number 50 Height of the selection
optionListRef function required Reference to <OptionList /> to display the selection menu
style object null Custom styles to be applied if supplied
defaultValue string first option The value to be displayed if none of the options are selected.
Option:
Property Type Default Description
style object null Styles to be applied on 'Option' component
styleText object null Styles to be applied on text inside of 'Option'

Demo

More Repositories

1

react-native-webview-bridge

React Native Webview with Javascript Bridge
Objective-C
1,367
star
2

example-react-native-redux

react native redux counter example
JavaScript
1,175
star
3

react-native-share-extension

react-native as an engine to drive share extension
Java
764
star
4

react-native-tabbar

Tab bar with more freedom
JavaScript
265
star
5

Proton.js

Tiny framework for writing inheritance in javascript
JavaScript
77
star
6

ssh-scp-action

Github actions for executing commands and uploading files to remote server
Shell
27
star
7

react-native-2-side-menus

The 2 Side Menus
JavaScript
22
star
8

callbag.go

golang implementation of Callbag
Go
20
star
9

react-native-logger

Async aware logger for react-native with grouping and filter feature
JavaScript
20
star
10

react-native-swiss-knife

Implementation of Missing APIs in React-Native
Java
19
star
11

react-native-updater

an open source version of AppHub!
Objective-C
15
star
12

react-native-pure-icon

Using Pure JS for displaying icon
Objective-C
12
star
13

ecs

Entity Component System in golang
Go
11
star
14

scopejs

The world's smallest dependency injection framework
JavaScript
7
star
15

react-native-double-buffer

Simple React Native Double Buffer
JavaScript
5
star
16

parcel-ssr-code-splitting

Super minimum Parcel, SSR(Streaming) and Code Splitting
JavaScript
5
star
17

JSON-2-SQLite

Tiny program which import JSON structure into SQLite
C++
4
star
18

hlc

Hybrid Logical Clocks
Go
4
star
19

baker.go

yet another dynamic http reverse proxy
Go
4
star
20

react-native-scene-manager

Simple Scene Manager for React-Native, use https://github.com/pressly/scene-router instead
JavaScript
3
star
21

mobx-navigation

simplified the integration of mobx on top of react-navigation.
JavaScript
3
star
22

react-native-request

simple wrapper around fetch api to make it easier to work with
JavaScript
3
star
23

git-release-note

Git flow release note generator
JavaScript
3
star
24

elm-vector2d

a Vector2D implemantion for Elm
Elm
2
star
25

script.go

a Github Action to write everything in Go
Go
2
star
26

maat

a markdown table to typescript compiler for configuration files
TypeScript
2
star
27

Castify.js

A wrapper around ChromeCast sender apis for Chrome browser.
JavaScript
2
star
28

mark.js

Tiny/Open framework for managing dependencies in JavaScript
JavaScript
2
star
29

ali.js

a node base tool
JavaScript
2
star
30

gowrk

gowrk is a simple benchmark utility for testing webpages that redirect
Go
2
star
31

include.js

Light and Simple dependency manager in JavaScript.
JavaScript
2
star
32

crypto.go

Common Crypto functions in Go
Go
2
star
33

deamon.go

golang signal interrupt made easy
Go
1
star
34

configator

configator is a set of tools to deal with configuration files
TypeScript
1
star
35

dope-stream

chainable node.js stream api
TypeScript
1
star
36

baker

simple and extendable http reverse proxy
Go
1
star
37

complex

complex is a WebGL2 game
TypeScript
1
star
38

json

fast and simple JSON parser implementation
Java
1
star
39

react-native-dimensions

normalized dimensions in react-native
JavaScript
1
star
40

react-native-through2

through2 for react-native
JavaScript
1
star
41

trie-route

yet another router implementation with trie at core
JavaScript
1
star
42

store-repository

simple and powerful singleton management
JavaScript
1
star
43

example-side-menu-redux

Example of using Redux to Control Side Menu
JavaScript
1
star
44

conceal

a tool to encrypt and decrypt `string` and `[]byte` fields in struct
Go
1
star
45

zero

zero width chars to hide your information
Go
1
star
46

go-boggle

Boggle Solver in Golang
Go
1
star
47

fsm.go

a finite state machine in Golang
Go
1
star
48

react-ssr-performance

testing ssr streaming and static performance
JavaScript
1
star
49

goproto

go wrapper which compiles all proto files in your project
Go
1
star
50

pkg.go

my pkg.go
Go
1
star
51

ella

yet another IDL for generating proper RPC for golang client/server and other languages
Go
1
star
52

example-cli

an example of creating self-updating golang cli with step by step guide
Go
1
star