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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-prefs-screen

v1.5.0

Published

React Native Preferences UI screen for iOS/Android

Readme

react-native-prefs-screen

React Native component for building a simple Settings/Preferences screen from a config object.

Supported platforms

  • Android
  • iOS

Installation

npm install react-native-prefs-screen react-native-dialog

or

yarn add react-native-prefs-screen react-native-dialog

Usage

Basic example

import React, { useRef } from 'react';
import { SafeAreaView } from 'react-native';
import { Preferences, PREF_TYPE } from 'react-native-prefs-screen';

const items = [
	{
		title: 'General',
		data: [
			{ id: 'wifi_only', name: 'wifi_only', text: 'Wi-Fi only', type: PREF_TYPE.SWITCH },
			{ id: 'username', name: 'username', text: 'Username', subtext: 'Shown in your profile', type: PREF_TYPE.TEXTINPUT },
			{
				id: 'quality',
				name: 'quality',
				text: 'Upload quality',
				type: PREF_TYPE.PICKER,
				pickerValues: { low: 'Low', medium: 'Medium', high: 'High' }
			},
			{ id: 'version', name: 'version', text: 'App version', type: PREF_TYPE.LABEL }
		]
	}
];

export default function PreferencesScreen() {
	const prefsRef = useRef(null);

	const values = {
		wifi_only: 1,
		username: 'alice',
		quality: 'medium',
		version: '1.5.0'
	};

	return (
		<SafeAreaView style={{ flex: 1 }}>
			<Preferences
				ref={prefsRef}
				items={items}
				getValue={(item) => values[item.name]}
				onChange={(item, value) => {
					values[item.name] = value;
				}}
			/>
		</SafeAreaView>
	);
}

Custom picker ordering

{
	id: 'quality',
	name: 'quality',
	text: 'Upload quality',
	type: PREF_TYPE.PICKER,
	pickerValues: { low: 'Low', medium: 'Medium', high: 'High' },
	pickerValuesSort: (a, b) => {
		const order = { high: 0, medium: 1, low: 2 };
		return order[a.id] - order[b.id];
	}
}

API

Exports

  • Preferences: main component
  • PREF_TYPE: item type enum
    • PREF_TYPE.TEXTINPUT
    • PREF_TYPE.SWITCH
    • PREF_TYPE.PICKER
    • PREF_TYPE.LABEL

Preferences props

  • items: Array (required in practice)
    • Array of section objects for SectionList.
  • getValue?: (item) => any
    • Called for every item to get the current value.
  • onChange?: (item, value) => void
    • Called when the user changes an item value.
  • onPress?: (itemName) => boolean | void
    • Called before default press handling.
    • Return false to cancel built-in behavior.
  • refreshControl?: object
    • Optional SectionList refresh control.
  • containerStyle?: object
    • Style passed to the internal SectionList.
  • testID?: string
    • Test ID for the internal SectionList.
  • styles?: object
    • Optional style overrides for internal style keys (sectionHeader, menuItem, menuItemText, etc.).

Section shape

{
	title: 'General',
	data: [/* preference items */]
}

Item shape

  • Common fields:
    • id: string
    • name: string (used as value key)
    • text: string (main label)
    • subtext?: string
    • type: PREF_TYPE.*
    • disabled?: boolean
    • testID?: string
  • TEXTINPUT:
    • keyboardType?: string
  • PICKER:
    • pickerValues?: Array<string> | Record<string, string>
    • pickerValuesSort?: (a, b) => number

TypeScript-style types

type PrefType =
	| typeof PREF_TYPE.TEXTINPUT
	| typeof PREF_TYPE.SWITCH
	| typeof PREF_TYPE.PICKER
	| typeof PREF_TYPE.LABEL;

type PickerOption = { label: string; id: string };

type PreferenceItem = {
	id: string;
	name: string;
	text: string;
	type: PrefType;
	subtext?: string;
	disabled?: boolean;
	testID?: string;
	keyboardType?: string; // TEXTINPUT
	pickerValues?: string[] | Record<string, string>; // PICKER
	pickerValuesSort?: (a: PickerOption, b: PickerOption) => number; // PICKER
};

type PreferenceSection = {
	title: string;
	data: PreferenceItem[];
};

type PreferencesProps = {
	items: PreferenceSection[];
	getValue?: (item: PreferenceItem) => any;
	onChange?: (item: PreferenceItem, value: any) => void;
	onPress?: (itemName: string) => boolean | void;
	refreshControl?: object;
	containerStyle?: object;
	testID?: string;
	styles?: Record<string, any>;
};

Notes

  • For SWITCH, incoming values from getValue are normalized to boolean using !!parseInt(value).
  • You can call queryValues() on the component ref to re-read values from getValue.
  • Android picker/text input dialogs use react-native-dialog; iOS uses native Alert.prompt / ActionSheetIOS.

Example project

https://github.com/nochkin/react-native-prefs-screen-examples