Skip to main content

Migrate from react-native-dropdown-picker

Select keeps its own open state, so open, setOpen and setItems go away, and onValueChange gets the new value rather than an updater. It opens as a dropdown on the web and a bottom sheet on phones, where a dropdown is cramped; set presentation="dropdown" to keep the dropdown everywhere.

- import DropDownPicker from 'react-native-dropdown-picker';
+ import { Select } from 'patine-ui';

- const [open, setOpen] = useState(false);
const [value, setValue] = useState(null);
- const [items, setItems] = useState([
- { label: 'Apple', value: 'apple' },
- { label: 'Banana', value: 'banana' },
- ]);
-
- <DropDownPicker open={open} value={value} items={items} setOpen={setOpen} setValue={setValue} setItems={setItems} />
+ <Select
+ options={[{ label: 'Apple', value: 'apple' }, { label: 'Banana', value: 'banana' }]}
+ value={value}
+ onValueChange={setValue}
+ />
react-native-dropdown-pickerPatine UI
items + setItemsoptions (adds description, icon, group, keywords)
value + setValuevalue + onValueChange(value, option)
open + setOpennot needed; or keep them as open + onOpenChange
onChangeValueonValueChange
multiplemultiple (selected items show as removable chips)
min / maxmaxSelected; check a minimum in your form
searchablesearchable (on by default past 8 options)
searchPlaceholdersearchPlaceholder
onChangeSearchText + disableLocalSearch + loadingonSearchChange + loading, or loadOptions(query) that returns a promise
placeholderplaceholder
disableddisabled
listMode="MODAL"presentation="modal"
listMode="FLATLIST" / "SCROLLVIEW"presentation="dropdown"
renderListItemrenderOption({ option, selected, disabled, theme })
addCustomItemonCreate(text): add the option to options and return it to select it (create new options)

See Select for groups, icons and render props, and server search.

See all migration guides for other libraries, and Comparison for when another library is the better choice.