Skip to content

Commit ab255a7

Browse files
committed
export Picker extractPickerItems as a static method
1 parent 0c16811 commit ab255a7

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/components/picker/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class Picker extends PureComponent {
143143
value: props.value,
144144
prevValue: undefined,
145145
selectedItemPosition: 0,
146-
items: this.extractPickerItems(props)
146+
items: Picker.extractPickerItems(props)
147147
};
148148

149149
if (props.mode === Picker.modes.SINGLE && Array.isArray(props.value)) {
@@ -183,6 +183,12 @@ class Picker extends PureComponent {
183183
return null;
184184
}
185185

186+
static extractPickerItems(props) {
187+
const {children} = props;
188+
const items = React.Children.map(children, child => ({value: child.props.value, label: child.props.label}));
189+
return items;
190+
}
191+
186192
getAccessibilityInfo() {
187193
const {placeholder} = this.props;
188194

@@ -196,12 +202,6 @@ class Picker extends PureComponent {
196202
};
197203
}
198204

199-
extractPickerItems(props) {
200-
const {children} = props;
201-
const items = React.Children.map(children, child => ({value: child.props.value, label: child.props.label}));
202-
return items;
203-
}
204-
205205
getContextValue = () => {
206206
const {value, searchValue} = this.state;
207207
const {mode, getItemValue, getItemLabel, renderItem, showSearch} = this.props;

typings/components/Picker.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,5 @@ export class Picker extends BaseComponent<PickerProps & ColorsModifiers> {}
6868

6969
export namespace Picker {
7070
export class Item extends BaseComponent<PickerItemProps> {}
71+
export function extractPickerItems(props: any): [{value: string, label: string}]
7172
}

0 commit comments

Comments
 (0)