MCPcopy
hub / github.com/lawnstarter/react-native-picker-select / getSelectedItem

Function getSelectedItem

src/index.js:105–123  ·  view source on GitHub ↗
({ items, key, value })

Source from the content-addressed store, hash-verified

103 }
104
105 static getSelectedItem({ items, key, value }) {
106 let idx = items.findIndex((item) => {
107 if (item.key && key) {
108 return isEqual(item.key, key);
109 }
110 if (isObject(item.value) || isObject(value)) {
111 return isEqual(item.value, value);
112 }
113 // convert to string to make sure types match
114 return isEqual(String(item.value), String(value));
115 });
116 if (idx === -1) {
117 idx = 0;
118 }
119 return {
120 selectedItem: items[idx] || {},
121 idx,
122 };
123 }
124
125 constructor(props) {
126 super(props);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected