Work with Alerts and Dialog Box in React Native

Shilpa S
Updated on 01-Jul-2021 08:11:12

957 Views

The Alert component helps to show a dialog box i.e., a pop up to the user with a title, message, buttons to know the confirmation from the user based on the message displayed.The basic component of Alert is as follows −Alert.alert('yourtile', 'yourmessage', [yourbuttons], ‘options’)To work with Alert component you need to import it as follows −import { Alert } from 'react-native';To get the pop-up you just have to call the Alert.alert() function. There are four params the alert() takes and it is title, message, buttons and options. The title is mandatory param and rest are optional.Here is a simple example ... Read More

Handle Touches in React Native

Shilpa S
Updated on 01-Jul-2021 08:06:59

619 Views

On a device the interaction with the UI mainly happens through a touch or tap. So when we use the app, we mostly tap the button to perform some action, or scroll the page by touching the screen, try to zoom the page etc. To handle these gestures like tap, touch reactnative has events that cap capture it or a touchable component to deal with touches it.Let us see the example of what happens when a button is clicked.Example 1: Handling Tap on ButtonHere is a simple example of Button. {       alert('You Tapped on Me!');    }} ... Read More

Working of the Modal Window in React Native

Shilpa S
Updated on 01-Jul-2021 08:02:48

393 Views

Modal component helps to display a content view above your UI content.The basic modal component is as follows − { Alert.alert("Modal has been closed."); }}> Your Content HereTo work with Modal component you need to import it first as follows −import { Modal } from "react-native";The basic properties of Modal Window is as follows −Sr.NoProps & Description1animationTypeThis property handles the animation for displaying the modal window.It is an enum with three values − slide, fade and none.2onDismissThis property takes in a function that will get called when the modal window is dismissed.3onOrientationChangeCallback function that is called when the device orientation ... Read More

Benefits of Using React Native for Building Mobile Apps

Shilpa S
Updated on 01-Jul-2021 07:53:46

185 Views

The increase in the popularity of IOs and Android apps nowadays there are lots of companies building apps and want them to develop in a faster way. A fully native app is getting very expensive as it requires separate teams to work on iOS and Android. ReactNative is a good solution to this as the app developed in react native can be run on ios and android.React Native is an open source mobile development framework that app developers prefer, to build an app that is cost effective and also saves time.React Native was a Facebook's hackathon project that was meant ... Read More

SectionList Component and How to Use It in React Native

Shilpa S
Updated on 01-Jul-2021 07:49:46

1K+ Views

An interface that helps to render the lists in sections. Some of the important features of SectionList are −Header/Footer support to the ListHeader/Footer support to the sectionScroll LoadingPull to refreshFully cross-platformThe basic SectionList component looks as follows −To work with SectionList import the component as shown below −import { SectionList } from "react-native";Here is a list of important properties available on a SectionList −PropsDescriptionrenderItemIs the default function that renders the item in the section. It returns a react element.The render function will be passed to sectionlist like an object with following keys −'item'(object) - the item object'index' (number) - Index ... Read More

FlatList Component in React Native: Usage Guide

Shilpa S
Updated on 01-Jul-2021 07:39:01

1K+ Views

FlatList is a container that can be used to load the list items. It offers header and footer support, multiple column support, comes with vertical/horizontal scrolling, lazy loading etc.Here are some important features of FlatList −Comes with scroll loadingAble to adjust the scroll by using ScrolltoIndex supportComes with header and footer supportMultiple column supportCross platformConfigurable viewability callbacksThe Basic structure of FlatList is as follows − item.id} />FlatList is implemented from the VirtualizedList component that takes care of displaying a limited number of items that will fit in the current view port of your mobile screen. The rest of the data ... Read More

ScrollView Component in React Native: Usage Guide

Shilpa S
Updated on 01-Jul-2021 07:29:51

769 Views

The ScrollView is a scrolling container that can accommodate multiple components and views. It is one of the core components in reactnative and using it you can scroll both vertically and horizontally.ScrollView will map to its native equivalent based on the platform it is running. So on android the view will map to , on iOS it will be and on the web environment.Example 1: Scrolling vertical using ScrollViewIn this example the ScrollView has a View along with a Text component and it is wrapped inside a View.To work with ScrollView import the component first −import { Text, ... Read More

What is a View Component and How to Use It in React Native

Shilpa S
Updated on 01-Jul-2021 07:24:52

906 Views

View is the most common as well as the core element in React Native. You can consider it as an equivalent of the div element used in web development.View will map to its native equivalent based on the platform it is running. So on android the view will map to , on iOS it will be and on the web environment.Use CasesLet us now see a few common use cases.When you need to wrap your elements inside the container, you can use View as a container element.When you want to nest more elements inside the parent element, both ... Read More

Add Styling or CSS to Your App Using React Native

Shilpa S
Updated on 01-Jul-2021 07:14:10

323 Views

Styling your app can be done as follows −Using Stylesheet componentUsing Inline stylesUsing Stylesheet componentReact native Stylesheet component comes very handy and neat when you want to apply styling to your app. To work with Stylesheet component first import it as shown below −import { StyleSheet } from 'react-native';You can create the style using Stylesheet component as follows −const styles = StyleSheet.create({    container: {       flex: 1,       marginTop: StatusBar.currentHeight || 0,    },    item: {       margin: 10,       padding: 20,       marginVertical: 8,       ... Read More

What are Props in React Native

Shilpa S
Updated on 01-Jul-2021 07:09:22

484 Views

Props are properties that help to modify the react component. The component created can be used with different parameters using props concept. With props you can pass the information from one component to another and at the same time re-use the component as per your requirement.You will be familiar with props if you are well versed with ReactJS, the same concepts follow in React Native.Let us take a look at an example that explains what props are.Example 1: Props inside React Native Built-in ComponentsConsider the Image component −The style and source are properties i.e props for the image component. The ... Read More

Advertisements