npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-selectbox

v0.1.2

Published

An OS independant take on the native react-native-picker with modal for selecting items

Downloads

35

Readme

react-native-selectbox

This is a platform independant (Android / iOS) version of the native picker / selectbox that react-native has. It's basically the Android version and the iOS version merged into one: only show a single selected label and only after clicking on this show the full list of items.

This is a derivation of the react-native-modal-picker by d-a-n I've simplified this a bit and removed alot of state handling preferring outside control. This allows for Redux state handling. I've also added the option of having the react-native-picker prompt feature. The prompt is a simple text above the list inside the modal.

Install

npm i react-native-selectbox --save

Usage

You can either use this component as an wrapper around your existing component or use it in its default mode. In default mode a customizable button is rendered.

See SampleApp for an example how to use this component.


import Selectbox from 'react-native-selectbox'

[..]

class App extends React.Component {

    ...

    _onChange = (item) => {
        // the full item as defined in the list of items is passed to the onChange handler to give full
        // flexibility on what to do... 
    }

    render() {
        const items = [
            { key: 0, label: 'Fruits', value:'some value' },
            { key: 1, label: 'Fruits', value:{this: "could", be:"anything"} },
        ];

        return (
            <View>
                <Selectbox
                    selectedItem=this.props.selectedItem
                    onChange={this._onChange}
                    items=items />
            </View>
        );
    }
}

Props

  • items - [] required, array of objects with a unique key and label
  • selectedItem - object required, the selected Item to be rendered directly
  • promptLabel - object optional, a string which will appear above the list of options / picker
  • cancelLabel - object optional, a string to be shown on the modal (defaults: cancel)
  • onChange - function optional, callback function, when the user selects an item
  • animationType - function optional, a string for the animation used to show the modal (defaults: slide)
  • transparent - function optional, a boolean value for the transparency of the modal
  • style - object optional, style definitions for the root element
  • optionLabelStyle - string optional, style definitions for each element from the options
  • selectLabelStyle - object optional, style definitions for currently selected item