Posts

Check Value is a Number using isNaN() in React Native

This is an Example to Check Value is a Number using isNaN() in React Native. The function isNaN() is used to check the value of any variable or state is a number or not. In this example we will check input is a number or not.

To Check Value is a Number or Not

It can be used in if condition, as it will return the true or false condition to identify the value, is a number or not. 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.

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).

This is how you can Check Value is a Number using isNaN() 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. 🙂

React Native Enable Disable TextInput Programmatically

This is an Example of React Native Enable Disable TextInput Programmatically. In this Example, we will make a TextInput Enable/Disable on a click of a button. This type of task can be used while making any form which has interdependent fields like F1 needs to be filed before F2, so in that case, you can disable F2 until the user fill the field F1. We will use editable prop of the TextInput to make it Enable or Disable. 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.

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).

IOS

     

Android

     

This is how you can enable or disable a TextInput. 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. 🙂

React Native Check TextInput is Empty or Not

This is an Example of React Native Check TextInput is Empty or Not. As the topic name describes itself, we will check the TextInput on a click of the Button. This is very useful if you are making any form which has some mandatory fields.

Check TextInput Using

In this example, we will check whether both inputs filled or not. 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.

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).

               

This is how you can check TextInput in empty or not. 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. 🙂

Image Icon in React Native TextInput

While working with React Native TextInput we need to assist the user what to insert in TextInput. We can use React Native Text with TextInput or we can show hint inside the TextInput but we can also add some icons to show the use of TextInput. Here is the example to show Image Icon In React Native TextInput.

To Import TextInput in Code

Render Using

In this example, we will make two TextInput with icons to enter the name and contact number. 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.

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).

IOS

Android

This is how you can add image icon inside the React Native TextInput. 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. 🙂

Example to Remove TextInput Underline in React Native

This is an Example to Remove TextInput Underline in React Native. While working with android you have seen an underline in android devices which is a default property for the Android. If you want to remove that you can use underlineColorAndroid prop which will decide the color of the underline in android.

Remove TextInput Underline Using

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.

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).

This is how you can remove TextInput Underline 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. 🙂

Example to Get Only Numeric Value From TextInput in React Native

This is an Example to Get Only Numeric Value From TextInput in React Native. This is used in many cases like when you have to take the mobile number of user you need the number to be inserted. Using this will open the Numeric Keyboard when the user clicks on the TextInput. We are going to use the TextInput prop numeric to get only Numeric value.

Get Only Numeric Value Using

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.

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).

     

This is how you can get an only numeric value from TextInput 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. 🙂

Example of Searching in List using Search Bar in React Native

Here is an Example of Searching in List using Search Bar in React Native. In our previous example of a search bar using TextInput, we have mentioned that searching is very important if we have a long list. It provides great user experience and control over the data to the App user. The user can easily search the data he/she requires using the search bar.

In this example of React Native Search Bar, we will make a search bar using a SearchBar component provided by react-native-elements.

The logic is simple

  • We will load the list from the network call and then show it to the user.
  • The user can search the data by entering the text in TextInput.
  • After inserting the text SearchFilterFunction will be called
  • We will compare the list data with the inserted data and will make a new data source.
  • We will update the data source attached with the ListView.
  • It will re-render the list and the user will be able to see the filtered data.

SearchBar Component

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 Dependencies

To use SearchBar we have to install react-native-elements and react-native-vector-icons dependencies.

For installation open the terminal and jump into your project using.

Run the following command.

This command will copy all the dependencies into your node_module directory, You can find the directories in node_module.

–save is optional, it is just to update the dependancies in your package.json file.

Linking of Dependencies

After installing the dependencies you need to link it with your project using

After linking the dependency if you face  Could not Compile Settings File project/android/settings.gradle error while building and installing the project then you can find the solution here.

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).

IOS

    

Android

    

This is how you can add a search bar to filter a list. 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. 🙂

Make Search Bar Filter for List View Data in React Native

This is an example to Make Search Bar Filter for List View Data in React Native. Basically, We will make a React Native FlatList with real-time searching ability. If we have a Long list in the app then it is very inconvenient to search the required data by scrolling the whole list.

Let’s take an example of E-Commerce which has the number of products and we have to choose our required product. You can imagine how tough it will be to search for a product by scrolling. So at this point, we need a Search Bar Filter on Listview so that we can easily search the required data and can save time.

In this Example of React Native Search Bar Filter on Listview, we are going to use a FlatList with a TextInput to work as the search bar.

For Real-Time Searching in List View using Search Bar Filter

The logic is simple

  • We will load the list from the network call and then show it to the user.
  • The user can search the data by entering the text in TextInput.
  • After inserting the text SearchFilterFunctionwill be called
  • We will compare the list data with the inserted data and will make a new Data source.
  • We will update the data source attached to the ListView.
  • It will re-render the list and the user will be able to see the filtered data.

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 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).

      

This is how you can make a Search bar filter on List View 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. 🙂

Example of Request Focus and Keyboard Avoiding View in React Native

This is an Example of Request Focus and Keyboard Avoiding View in React Native. While working with TextInput in native app development we don’t have to take care of the focus and keyboard avoiding because it is done by the app itself but in case of React Native, we have to take care of all this stuff so that we can provide a full native feel to the user.

Request Focus is used to set the focus to the TextInput while the keyboard is up and visible. It also helps to navigate to the next TextInput Using the following way.

Request Focus Use

Keyboard Avoiding View is used to close the keyboard. It wraps the whole form that we made using TextInput and close the keyboard if touched outside the TextInput. It is very helpful in the case of IOS because it does have a back button to close the keyboard. This feature is by default in React Native TextInput but if we are using Request Focus then sometimes it becomes very essential to use the Keyboard Avoiding View.

KeyboardAvoidingView Use

So Let’s get started with the example, In this example, we will make a Registration Form which will use TextInput with Icon and we will use Request Focus and Keyboard Avoiding View both.

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 Dependencies

To use Icon we have to install react-native-elements and react-native-vector-icons dependencies.

For installation open the terminal and jump into your project using

Run the following command

This command will copy all the dependencies into your node_module directory, You can find the directories in node_module.

–save is optional, it is just to update the dependancies in your package.json file.

Linking of Dependencies

After installing the dependencies you need to link it with your project using

After linking the dependency if you face  Could not Compile Settings File project/android/settings.gradle error while building and installing the project then you can find the solution here.

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).

IOS

         

Android

         

.

That was the Request Focus and Keyboard avoiding view 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. The remaining components will be covered in the next article. Stay tuned!

Hope you liked it. 🙂