Javascript Articles

Page 178 of 534

How to work with Alerts Dialog box in ReactNative?

Shilpa S
Shilpa S
Updated on 15-Mar-2026 1K+ Views

The Alert component in React Native displays dialog boxes to users with a title, message, and buttons for user interaction. It's essential for getting user confirmation or displaying important information. Syntax Alert.alert(title, message, buttons, options) Parameters To work with Alert component you need to import it first: import { Alert } from 'react-native'; The Alert.alert() function takes four parameters: title (required): The title of the alert dialog message (optional): The message to display buttons (optional): Array ...

Read More

How to load data from a server in React Native?

Shilpa S
Shilpa S
Updated on 15-Mar-2026 1K+ Views

To load data from the server you can make use of the fetch API that is similar to XMLHttpRequest or any other networking APIs. It is very easy to make a request to the server using fetch. Take a look at the following code: fetch('https://jsonplaceholder.typicode.com/posts/1') .then((response) => response.json()) .then((responseJson) => console.log(responseJson)); In above code we are fetching the JSON file https://jsonplaceholder.typicode.com/posts/1 and printing the data to the console. The simplest call to fetch() API takes in one argument i.e the path you want to fetch and it returns a promise with ...

Read More

Write a program to display "Hello World" in react native?

Shilpa S
Shilpa S
Updated on 15-Mar-2026 1K+ Views

Once React Native is installed on your system, you get a default code in App.js. This tutorial shows how to modify it to display "Hello World" on your mobile screen. Default App.js Structure When you create a new React Native project, the default App.js contains the following structure: import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; export default class App extends React.Component { render() { return ( ...

Read More

How to display loading indicator in React Native?

Shilpa S
Shilpa S
Updated on 15-Mar-2026 3K+ Views

Loading indicators are essential UI components that inform users when a request is processing. In React Native, the ActivityIndicator component provides an elegant solution for displaying loading states during API calls, form submissions, or data fetching operations. Import Statement To use the ActivityIndicator, import it from React Native: import { ActivityIndicator } from 'react-native'; Basic Syntax Properties Property Description Type ...

Read More

How to show ProgressBar in ReactNative?

Shilpa S
Shilpa S
Updated on 15-Mar-2026 979 Views

ProgressBar is a way to tell users that the content will be available in sometime. It can best be used when you submit something to the server and wait for the server to respond. To work with the progress bar component install react-native-paper module using npm. The command to install react-native-paper is − npm install --save-dev react-native-paper Basic Syntax The basic component of progress bar is as follows− To work with Progress Bar you need to import it from react-native-paper as follows − import { ProgressBar} ...

Read More

Explain the importance of SafeViewArea in React Native?

Shilpa S
Shilpa S
Updated on 15-Mar-2026 364 Views

The SafeAreaView component in React Native ensures your content displays within the safe boundaries of a device screen. It automatically adds padding to prevent content from being covered by system elements like the status bar, navigation bar, toolbar, and tab bars. While originally designed for iOS devices with notches and home indicators, it's now essential for modern app development across platforms. The Problem Without SafeAreaView When using regular View components, content can render underneath system UI elements, making it partially or completely hidden from users. Example: Text Overlapping Status Bar The following example shows how text ...

Read More

How to display dropdown in ReactNative?

Shilpa S
Shilpa S
Updated on 15-Mar-2026 1K+ Views

React Native provides the Picker component (now deprecated) and modern alternatives for creating dropdown selections. This guide covers both approaches. Basic Picker Syntax The traditional Picker component follows this structure: Import the Picker component from React Native: import { Picker } from 'react-native' Picker Properties Property Description enabled Boolean value. If false, picker is disabled and user cannot select items. itemStyle Styling to be applied to picker items. ...

Read More

Explain VirtualizedList component usage in ReactNative?

Shilpa S
Shilpa S
Updated on 15-Mar-2026 3K+ Views

The VirtualizedList component is React Native's most performance-optimized component for rendering large datasets. Unlike regular lists that render all items at once, VirtualizedList only renders visible items and recycles components as users scroll, dramatically improving memory usage and scroll performance. The basic structure of VirtualizedList requires several mandatory props: Essential VirtualizedList Properties Props Description ...

Read More

How to handle navigation from one page to another in react native?

Shilpa S
Shilpa S
Updated on 15-Mar-2026 4K+ Views

While working on the app, we would like to switch from one screen to another and that is handled by React Navigation library. Installation To work on navigating pages we need to install few packages as follows: npm install @react-navigation/native @react-navigation/stack npm install @react-native-community/masked-view react-native-screens react-native-safe-area-context react-native-gesture-handler Once you are done with the above installation let us now proceed with the next setup of navigation in React Native. Creating Page Components In your app project create a folder called pages/. Create 2 js files HomePage.js and AboutPage.js. pages/HomePage.js import ...

Read More

How to handle errors while working with Navigation in ReactNative?

Shilpa S
Shilpa S
Updated on 15-Mar-2026 1K+ Views

Problem: How to handle the error "A navigator can only contain 'Screen' components as its direct children" while working with Navigation in ReactNative? Solution While working on your app you may come across issues like stated above. Here we'll understand why such error comes up and what can be done to avoid it. Here is the code that gives us the error: Example with Error App.js import * as React from 'react'; import { NavigationContainer } from '@react-navigation/native'; import { createStackNavigator } from '@react-navigation/stack'; import { Button, View, Alert, Text } from 'react-native'; ...

Read More
Showing 1771–1780 of 5,340 articles
« Prev 1 176 177 178 179 180 534 Next »
Advertisements