1.0.1 • Published 4 years ago

react-native-dropdown-component v1.0.1

Weekly downloads
8
License
-
Repository
-
Last release
4 years ago

react-native-dropdown

Demo

npm.io npm.io

Getting started

$ npm install react-native-dropdown-component --save

Mostly automatic installation

$ react-native link react-native-dropdown-component

Manual installation

iOS

1. In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name] 2. Go to node_modules ➜ react-native-dropdown-component and add RNDropdown.xcodeproj 3. In XCode, in the project navigator, select your project. Add libRNDropdown.a to your project's Build Phases ➜ Link Binary With Libraries 4. Run your project (Cmd+R)<

Android

1. Open up android/app/src/main/java/[...]/MainActivity.java   - Add import com.reactlibrary.RNDropdownPackage; to the imports at the top of the file   - Add new RNDropdownPackage() to the list returned by the getPackages() method 2. Append the following lines to android/settings.gradle:       include ':react-native-dropdown-component'       project(':react-native-dropdown-component').projectDir = new File(rootProject.projectDir,     '../node_modules/react-native-dropdown-component/android') 3. Insert the following lines inside the dependencies block in android/app/build.gradle:       compile project(':react-native-dropdown-component')

Windows

Read it! :D

1. In Visual Studio add the RNDropdown.sln in node_modules/react-native-dropdown/windows/RNDropdown.sln folder to their solution, reference from their app. 2. Open up your MainPage.cs app   - Add using Dropdown.RNDropdown; to the usings at the top of the file   - Add new RNDropdownPackage() to the List<IReactPackage> returned by the Packages method

Usage

import RNDropdown from 'react-native-dropdown-component';

const Menus = [
  {
    key: '1',
    name: '订单类型',
    activeItems: ['all'],
    items: [
      { key: 'all', name: '全部' },
      { key: 'server', name: '服务下单' },
    ],
  },
  {
    key: '2',
    name: '订单状态',
    activeItems: ['hignest'],
    items: [
      { key: 'newest', name: '最新发布' },
      { key: 'hignest', name: '最高预算' },
    ],
  },
];

<RNDropdown
  menus={Menus}
  onSelected={(result) => {console.log(result)}}
  multiple
/>

Props

PropTypeRequiredDefaultDescription
menusarrayYesArray with header menus and drop-down list
onSelectedfuncYes(result: []) => {}Each choose, will return to the selected item
multiplebooleanNofalseUse multiple selection
okTextstring or JSX.ElementNoOKOnly show when mutiple is true
cancelTextstring or JSX.ElementNoCancelOnly show when mutiple is true
okTextStyleobjectNocss style of okText
cancelTextStyleobjectNocss style of cancelText