Socket
Socket
Sign inDemoInstall

react-native-segmented-picker

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-segmented-picker - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "react-native-segmented-picker",
"version": "1.0.0",
"version": "1.0.1",
"description": "A segmentable dropdown picker wheel with no native dependencies.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -10,5 +10,5 @@ # React Native Segmented Picker

- Supports one or many columns (list segments).
- Show any data in the picklists, not just dates and times.
- Show any data in the picklists, not just [dates and times](https://github.com/henninghall/react-native-date-picker).
- Customisable colors and sizing.
- Does not rely on native dependencies (`npm link` not required).
- Does not rely on native dependencies (`react-native link` not required).
- Works with apps built on [Expo](https://expo.io).

@@ -60,3 +60,3 @@

column2: [
{ label: 'Option 3' },
{ label: 'Option 3', key: 'option_3' },
],

@@ -78,3 +78,3 @@ }}

|------------------------------|--------------------------------------------------------------------------------|-------------|
| `options` | Data to be populated into the picklists. `{columnId: [{label: ''}, ...], ...}` | |
| `options` | Data to be populated into the picklists. `{columnId: [{label: '', key: ''}, ...], ...}` | |
| `visible` | Not used by default. Set to `true` or `false` to manually handle visibility. | `null` |

@@ -81,0 +81,0 @@ | `defaultSelections` | Eg: `{columnId: 'label string to auto-select', ...}` | `{}` |

@@ -466,5 +466,9 @@ import React, { Component } from 'react';

<FlatList
data={options[column].map(({ label }) => ({ label, column }))}
data={options[column].map(({ label, key }) => ({
label,
key,
column,
}))}
renderItem={this._renderPickerItem}
keyExtractor={item => `${column}_${item.label}`}
keyExtractor={item => `${column}_${item.key || item.label}`}
initialNumToRender={40}

@@ -471,0 +475,0 @@ getItemLayout={(data, index) => (

import React from 'react';
import 'react-native';
import { FlatList } from 'react-native';
import renderer from 'react-test-renderer';

@@ -86,2 +86,27 @@ import SegmentedPicker from './SegmentedPicker';

it('Sets the react "key" of list items correctly', () => {
const column1 = 'column1';
const listData = {
[column1]: [
{ label: 'Adam' },
{ label: 'Francesca', key: 'fran' },
],
};
const testRenderer = renderer.create(
<SegmentedPicker
visible
options={listData}
/>,
);
const testInstance = testRenderer.root;
jest.advanceTimersByTime(1000);
const {
props: { data, keyExtractor: listItemKeyExtractor },
} = testInstance.findByType(FlatList);
expect(listItemKeyExtractor(data[0]))
.toBe(`${column1}_${listData[column1][0].label}`);
expect(listItemKeyExtractor(data[1]))
.toBe(`${column1}_${listData[column1][1].key}`);
});
it('Can be shown and hidden programmatically.', () => {

@@ -88,0 +113,0 @@ const ref = React.createRef();

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc