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

@ouroboros/react-native-picker

v0.3.1

Published

A replacement Picker for React-Native that relies on no other packages

Downloads

124

Readme

@ouroboros/react-native-picker

npm version Supports Android, iOS, Expo MIT License

Coming to the react-native party a bit late, I discovered that the standard Picker component no longer seems to exist, that it was removed from React-Native sometime at the end of 2021 in favour community packages which themselves started to break in 2022 due to no Picker being available. Since no alternative was presented, and I liked the look and feel of the iOS picker, I decided to attempt to recreate it using in pure react native components and offer it up to the community.

Installation

react-native

npm install @ouroboros/react-native-picker

expo

expo install @ouroboros/react-native-picker

Getting Started

Import Picker

import Picker from '@ouroboros/react-native-picker';

Create a state variable for the picker value:

let [picker, setPicker] = useState('CA');

Add the Picker to your component:

<Picker
    onChanged={setPicker}
    options={[
        {value: 'CA', text: 'Canada'},
        {value: 'MX', text: 'Mexico'},
        {value: 'US', text: 'United States'}
    ]}
    style={{borderWidth: 1, borderColor: '#a7a7a7', borderRadius: 5, marginBottom: 5, padding: 5}}
    value={picker}
/>

Custom Display

Instead of defaulting to a read-only TextInput, you can specify your own component to handle displaying the currently selected value.

import Picker from '@ouroboros/react-native-picker';
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'
import { faCaretDown } from '@fortawesome/free-solid-svg-icons/faCaretDown';
import { useState } from 'react';
import { Text, View } from 'react-native';

function PickerDisplay(props) {
    return (
        <View>
            <Text>{props.text}</Text>
            <FontAwesomeIcon icon={faCaretDown} />
        </View>
    );
}

function App() {
    let [picker, setPicker] = useState('CA');
    return (
        <View>
            <Picker
                component={PickerDisplay}
                onChanged={setPicker}
                options={[
                    {value: 'CA', text: 'Canada'},
                    {value: 'MX', text: 'Mexico'},
                    {value: 'US', text: 'United States'}
                ]}
                value={picker}
            />
        </View>
    );
}

Props

| Name | Type | Required | Description | |--|--|--|--| | component | Component | No | A React component which will be used to generate the display instead of a TextInput. Receives the text prop which corresponds to the text of the currently selected option. If set, style and textAlign props are ignored. | | onChanged | Function | Yes | A callback function which receives the new value selected by the user as the only argument | | options | Object[] | Yes | Array of Objects with the value and text properties for each option to be shown | | style | object|object[] | No | A single Obejct of styles values or an Array of styles objects to be passed to the input displayed in your component | | textAlign | ['left', 'center', 'right'] | No | The alignment of the text in the input | | value | mixed | Yes | The current value selected in the Picker |