Posts

Example of Searchable Dropdown / Picker in React Native

This is an Example of Searchable Dropdown / Picker in React Native. To make a Searchable Dropdown in React Native we have a SearchableDropdown component provided by react-native-searchable-dropdown.

React Native Picker is the component which can be used as a drop-down but in case of huge data we have to give the facility to search for the option for that we can use Searchable Dropdown.

Searchable Dropdown in React Native

In this example of Searchable Dropdown, we will make 2 searchable drop-downs. One of them will have the data from the static array and the other one have the data from calling the rest API. So Let’s get started.

To Make a React Native App

Getting started with React Native will help you to know more about the way you can make a React Native project. We are going to use react-native init to make our React Native App. Assuming that you have node installed, you can use npm to install the react-native-cli command line utility. Open the terminal and go to the workspace and run
npm install -g react-native-cli
Run the following commands to create a new React Native project
react-native init ProjectName
This will make a project structure with an index file named App.js in your project directory.

Installation of Dependency

To use SearchableDropdown component you need to install react-native-searchable-dropdown dependency.

To install this open the terminal and jump into your project

Run the following command

This command will copy all the dependencies into your node_module directory, You can find the directory in node_module directory named react-native-searchable-dropdown.

Dependencies for this example

Now Open App.js in any code editor and replace the code with the following code.

App.js

To Run the React Native App

Open the terminal again and jump into your project using.
cd ProjectName
To run the project on an Android Virtual Device or on real debugging device
react-native run-android
or on the iOS Simulator by running
react-native run-ios (macOS only).

That was the example of the searchable dropdown/picker in React Native. If you have any doubt or you want to share something about the topic you can comment below or contact us here. There will be more posts coming soon. Stay tuned!

Hope you liked it. 🙂

Understanding of How Picker works in React Native

This post will give you an Understanding of How Picker Works in React Native. React Native Picker is a component for selection between different choice same as a Dropdown. Picker can be used when we have to give an option to pick one. There are multiple types of picker available which we will see one by one in upcoming tutorials. Have a look at the simple picker which has multiple options and the user has to choose one.

To Import Picker in Code

Render Using

To Make a React Native App

Getting started with React Native will help you to know more about the way you can make a React Native project. We are going to use react-native init to make our React Native App. Assuming that you have node installed, you can use npm to install the react-native-cli command line utility. Open the terminal and go to the workspace and run
npm install -g react-native-cli
Run the following commands to create a new React Native project
react-native init ProjectName
This will make a project structure with an index file named App.js in your project directory.

Open App.js in any code editor and the Replace the code with the following code.

App.js

To Run the React Native App

Open the terminal again and jump into your project using.
cd ProjectName
To run the project on an Android Virtual Device or on real debugging device
react-native run-android
or on the iOS Simulator by running
react-native run-ios (macOS only).

        

That was the React Native Picker. If you have any doubt or you want to share something about the topic you can comment below or contact us here. The remaining components will be covered in the next article. Stay tuned!

Hope you liked it. 🙂