How to use SetTimeout in React Native?




How to use SetTimeout in React Native?

Hi Guys,

Hello all! In this article, we will talk about how to use setTimeout in react native. I would like to show you how to create setTimeout in react native. if you want to see example of react native setTimeout example then you are a right place. I explained simply step by step how to implement setTimeout in react native. you will do the following things for setTimeout in react native.

Sometimes, we may need to execute code after some delay. In such cases, we use JavaScript method setTimeout in React Native. SetTimeout method is used to execute a function after waiting a specific amount of time.

Let's start following example:

Step 1: Download Project

In the first step run the following command to create a project.

expo init ExampleApp

Step 2: App.js

In this step, You will open the App.js file and put the code.

import React from 'react';

import { Button, Image, StyleSheet, View} from 'react-native';

const App = () => {

const [image, setImage] = React.useState(null);

const showImage = () => {

setTimeout(() => {


}, 3000);


return (

<View style={styles.container}>

<View style={styles.imageContainer}>


source={{ uri: image }}

style={{ width: '100%', height: 160 }}




<View style={styles.buttonContainer}>


title='Show Image'

onPress={() => showImage()}






const styles = StyleSheet.create({

container: {

flex: 0.85,

justifyContent: 'center',

paddingHorizontal: 10,


buttonContainer: {

marginTop: 10,


imageContainer: {

justifyContent: 'center',

alignItems: 'center',



export default App;

Run Project

In the last step run your project using the below command.

expo start

You can QR code scan in Expo Go Application on mobile.

Output :

It will help you...

#React Native