Socket
Socket
Sign inDemoInstall

device-picker

Package Overview
Dependencies
14
Maintainers
19
Versions
33
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    device-picker

[![npm version](https://img.shields.io/npm/v/device-picker.svg?style=flat-square)](https://www.npmjs.com/package/device-picker)


Version published
Weekly downloads
12
decreased by-14.29%
Maintainers
19
Install size
23.1 MB
Created
Weekly downloads
 

Readme

Source

Device Picker

npm version

Device Picker Demo

Installation

npm install device-picker

Usage

import React from 'react';
import { View, DevicePicker } from 'device-picker';
import memoize from 'lodash/memoize';
function MyDevicePicker() {
   return (
         <DevicePicker
            allowOrphan={true}
            initialDevice={'iPhone'}
            initialView={View.Grid}
            fetchHierarchy={() =>
               fetch(
                  'https://www.cominor.com/api/2.0/wikis/CATEGORY?display=hierarchy',
               ).then(response => response.json())
            }
            fetchChildren={
                memoize(title =>
                    fetch(
                        `https://www.cominor.com/api/2.0/wikis/CATEGORY/${title}/children`,
                    ).then(response => response.json()),
                )
            }
            onSubmit={title => alert(`Selected "${title}"`)}
            onCancel={() => alert(`Cancelled`)}
            objectName="device"
         />
   );
}

export default MyDevicePicker;

Props

PropTypeDefaultRequiredDescription
allowOrphanbooleanfalseNo
initialDevicestring''NoDefault device to load picker with.
initialViewViewView.GridNoDefault layout for displaying devices. Available options View.Grid, View.Column. For IE defaults to View.Column
fetchHierarchyfunctionundefinedYesFunction to get devices categories
fetchChildrenfunctionundefinedYesFunction to get category items
onSubmitfunctionundefinedYesFunction that receives the device title.
onCancelfunctionundefinedYesFunction when picker is cancelled.
objectNamestringdeviceNoSingular object name for objects, usually "Device" or "Category".

Sample Integration

Contributing

Local development setup

Clone repo

git clone https://github.com/iFixit/device-picker.git

Change directory

cd device-picker

Install dependencies

npm install

Start dev server

npm run dev

FAQs

Last updated on 13 Jan 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc