Use Console.log() in React Native Functional Component

Hello friends, In today’s tutorial we would learn about Console.log() function of JavaScript which can use also in react native. The console is used to debug apps in react native. It can print any possible output at any place with a defined output value. The main purpose of console is to see if there are any error present in our code or we’re receiving data correctly. So when we print a object or data into a List or component then it is receiving correctly. So in this tutorial we would learn about Use Console.log() in React Native Functional Component.

For Example :- When we receive a JSON data object form sever and for some reason it is not rendering on screen in List correctly. Then using the Console we can print it earlier before rendering on Bash screen. So If there is data showing on the bash screen then there are definitely some coding error. If there is also not showing the data then we know for sure that the JSON data is not coming from server and our URL might not be right.

Contents in this project How to Use Console.log() in React Native Functional Component :-

1. Open your project’s main App.js file and import useEffect, useState, StyleSheet, Button, SafeAreaView and View component.

2. Creating our main App component.

3. Creating useEffect() with Empty Array which works same as Componentdidmount(). Here we would write the code of Console.

4. Creating a Array named as tempArray . We would print this Array value in Console.

5. Creating a variable named as A with default value of 10. We would also print this value on Bash Screen using console.

6. Creating a function named as printConsole(). In this function we would simply print multiple Console.

7. Creating return() block. Here we would make also make multiple Console to see which part execute first.

8. Creating Style.

9. Complete Source Code for App.js File :-

Screenshots :-

Use Console.log() in React Native Functional ComponentThe Console.log() output will be shown on the NPM server running Bash window.

Leave a Reply

Your email address will not be published. Required fields are marked *