Home » React-native » Top React Native Interview Questions 2025 | Complete Guide for Developers

Top React Native Interview Questions 2025 | Complete Guide for Developers

Pro Level React-native
Top React Native Interview Questions 2025 | Complete Guide for Developers

In 2025, React Native continues to be one of the most popular frameworks for cross-platform mobile app development. Many leading tech companies are actively hiring skilled React Native developers, and interviews often include challenging questions that test both JavaScript fundamentals and deep knowledge of React Native. In this article, we’ve curated the top React Native interview questions for experienced developers, designed to help you prepare with confidence and stand out in competitive interviews.

Top React Native Interview Questions 2025 | Complete Guide for Developers

1. Can you tell me what will be the output code that I pasted in the chat box?

console.log(name);
console.log(age);
console.log(address);
var name = "Jim";
const age = 30;
let address = "Mumbai";

Answer: For this question, they accept the following explanation from you.

There are a couple of things to note. Firstly, when you try to log the name variable before it is defined, it will result in an undefined being printed to the console. This is because the variable is declared using the var keyword, which gets hoisted to the top of its scope but does not have an initial value assigned at that point.

Secondly, when trying to log the age variable, it will throw a ReferenceError because const variables must be initialized when declared, and they cannot be reassigned or redeclared.

Lastly, when trying to log the address variable, it will also throw a ReferenceError because let the variables are block-scoped and cannot be accessed before they are declared.

2. What is the difference between var, let & const?

  • var: JavaScript treats variables declared with var as function-scoped or global-scoped, depending on where you declare them. The engine hoists them to the top of their scope, so you can access them before declaration. You can redeclare and reassign var within the same scope.
  • let: Variables declared with let stay block-scoped, meaning you can access them only inside the block where you declare them. JavaScript does not hoist let in a usable way, so you cannot access them before declaration. You can reassign let but cannot redeclare it in the same scope.
  • const: Variables declared with const also stay block-scoped. You must initialize them at the time of declaration, and once assigned, you cannot reassign them.
const array = [{name: "First"}, {name: "Second"}]
array[0].name = 0;
console.log(array);

Note: Now,  you will get confused because as per the previous question, const variables are only read-only but in the above code it will update the value of the array. read-only means you cannot assign a new array to a const variable array. so the output will be as follows:

[{name: 0}, {name: "Second"}]

4. What is variable Hoisting?

Variable hoisting in JavaScript means the engine moves variable declarations to the top of their scope during compilation. Only variables declared with var support hoisting. This behavior lets you assign a value before the declaration appears in the code.

a = 5;
console.log(a);
var a;

This prints 5 because:

  1. The JavaScript engine sees var a; first by hoisting it to the top of the global scope.

  2. Then it processes the assignment a = 5;.

  3. Finally, console.log(a); outputs 5.

So even though you wrote the assignment before the declaration, hoisting makes the code work.

As a result, when console.log(a) is executed, it will output 5 to the console, indicating that the value assigned to a is accessible and correctly retrieved.

It’s important to note that while hoisting allows the code to run without errors, it is generally considered best practice to declare variables before using them to improve code readability and maintainability.

5. What are promises?

Promises in Javascript are the way to handle asynchronous operations such as fetching data from the server, reading files, and executing time-consuming tasks. without blocking the execution of the program.

A promise represents the eventual completion or failure of an asynchronous operation and allows you to attach callbacks to handle the result when it becomes available.

  1. Pending: The initial state of a promise. It is neither fulfilled nor rejected.
  2. Fulfilled: The state of a promise when it successfully completes the asynchronous operation, providing the result value.
  3. Rejected: The state of a promise when it encounters an error or fails to complete the asynchronous operation, providing the reason for the failure.

example,

const delay = (duration) => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve(`Operation completed after ${duration} milliseconds`);
    }, duration);
  });
};

delay(2000)
  .then((result) => {
    console.log(result);
  })
  .catch((error) => {
    console.log(error);
  });

6. What is Callback?

A callback is a function that you pass as an argument to another function, and that function later executes it. In JavaScript, developers often use callbacks to handle asynchronous operations or run specific actions after a task or event finishes.

Callbacks let you define custom behavior that runs when a condition is met or when an asynchronous operation completes. They give you control over the program’s flow and allow you to handle results as soon as they are available.

function fetchData(callback) {
  // Simulating an asynchronous operation
  setTimeout(() => {
    const data = { id: 1, name: "John Doe" };
    callback(data);
  }, 2000);
}

function processResult(data) {
  console.log("Processing data:", data);
}

fetchData(processResult);

7. What is an Event loop?

The event loop is the mechanism that continually listens to events & executes them and moves to the next one if the task queue is empty. It ensures that tasks are processed in a non-blocking manner, allowing for efficient handling of events and responsiveness in JavaScript applications. Let’s explore an example to understand how the event loop works:

console.log("Start");

setTimeout(() => {
  console.log("setTimeout");
}, 0);

Promise.resolve().then(() => {
  console.log("Promise");
});

console.log("End");

Here’s how the event loop handles this code:

  1. The code starts running, and the console logs “Start”.

  2. The program reaches setTimeout. It schedules the callback to run after a minimum delay of 0 ms. That callback will log “setTimeout” when executed.

  3. The program reaches Promise.resolve().then(). It schedules a microtask that will run as soon as the call stack becomes empty. That microtask contains the callback that logs “Promise”.

  4. The console logs “End”.

  5. Now the call stack is empty. The event loop checks the microtask queue.

  6. The event loop takes the microtask, places its callback on the call stack, and executes it. The console logs “Promise”.

  7. The microtask finishes, and the call stack becomes empty again.

  8. The event loop then checks the task queue and finds the setTimeout callback.

  9. It places that callback on the call stack and executes it. The console logs “setTimeout”.

  10. The setTimeout task finishes.

Output:

Start
End
Promise
setTimeout

Note: Promise microtask, created by Promise.resolve().then(), has higher priority than the setTimeout task. This means that microtasks, such as Promises, are processed before tasks like setTimeout in the event loop.

8. What is MicroTask?

It represents the queue of the task which executes asynchronously with higher priority than regular tasks. When a microtask is created, it is added to the microtask queue. The event loop processes this queue after completing the current task and before moving on to the regular task queue. This means that microtasks have a higher priority and are executed before regular tasks.

Here’s an example to illustrate the concept of microtasks:

console.log('Start');

Promise.resolve().then(() => {
  console.log('Microtask 1');
}).then(() => {
  console.log('Microtask 2');
});

console.log('End');

Output:

Start
End
Microtask 1
Microtask 2

9. What is Block scoping?

It refers to the behavior of the variable being limited to the nearest closing block. such as within a set of curly braces {}, are limited in scope to that specific block and its nested blocks. This means that variables defined inside a block are not accessible outside of that block.

Let’s look at an example to understand block scoping in JavaScript:

function exampleFunction() {
  var x = 10;
  
  if (x > 5) {
    let y = 20;
    const z = 30;
    console.log(x, y, z); // Output: 10 20 30
  }
  
  console.log(x); // Output: 10
  console.log(y); // ReferenceError: y is not defined
  console.log(z); // ReferenceError: z is not defined
}

10. What is closure?

A closure combines a function with the lexical environment where you declared it. This environment lets the function access and remember variables from its outer scope even after the outer function finishes running.

In simpler terms, when a nested function accesses variables from its outer function—even after the outer function has returned—you create a closure.

function outerFunction() {
  var outerVariable = 'Hello';

  function innerFunction() {
    console.log(outerVariable);
  }

  return innerFunction;
}

var closure = outerFunction();
closure(); // Output: Hello

11. What is Virtual DOM?

Virtual DOM is a complete representation of real DOM. it refers to the layer between the application and the real DOM. It provides an abstraction to the framework by efficiently managing & update the UI without manipulating to real DOM.

The Virtual DOM creates a lightweight, in-memory copy of the real DOM. React updates this virtual copy whenever the UI changes. It then compares the new Virtual DOM with the previous version to find the differences. Instead of re-rendering the entire UI, React applies only the necessary changes to the real DOM. This approach makes UI updates faster and more efficient.

12. What is async/await?

The async keyword is used to declare an asynchronous function, which returns a promise. Within an async function, you can use the await keyword to pause the execution of the function until a promise is resolved or rejected.

Here’s an example to illustrate the usage of async/await:

function delay(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

async function example() {
  console.log('Start');
  
  await delay(2000);
  console.log('After 2 seconds');
  
  await delay(1000);
  console.log('After another 1 second');

  return 'Done';
}

example().then(result => {
  console.log(result);
});

Output: It will first print Start. then it waits for 2000 milliseconds and then displays After 2 seconds. again wait for 1000 milliseconds then displays After another 1 second then it will return Done. basically, it will wait until the delay function completes its execution and return a promise.

13. What are controlled and uncontrolled components?

1. Controlled components
A controlled component is a form element that relies on React state as its single source of truth. The component’s state stores the input value, and React updates the value whenever the state changes. Any user input triggers an event handler (like onChange) that updates the state, and in turn, the state updates the UI.

import React, { useState } from 'react';

function ControlledComponent() {
  const [value, setValue] = useState('');

  const handleChange = (event) => {
    setValue(event.target.value);
  };

  return (
    <input type="text" value={value} onChange={handleChange} />
  );
}

2. Uncontrolled components

An uncontrolled component is a form element that maintains its own internal state, independent of the application’s state. The component updates its internal state without involving the application’s state. To access the value of an uncontrolled component, you typically use a ref or obtain the value directly from the DOM.

import React, { useRef } from 'react';

function UncontrolledComponent() {
  const inputRef = useRef();

  const handleSubmit = (event) => {
    event.preventDefault();
    console.log('Input value:', inputRef.current.value);
  };

  return (
    <form onSubmit={handleSubmit}>
      <input type="text" ref={inputRef} />
      <button type="submit">Submit</button>
    </form>
  );
}

14. What are the inbuilt functions in Javascript?

  1. console.log(): Outputs messages to the console for debugging and logging purposes.
  2. alert(): Displays an alert dialog box with a specified message.
  3. prompt(): Displays a dialog box to prompt the user for input.
  4. parseInt(), parseFloat(): Converts a string to an integer or floating-point number.
  5. String(): Converts a value to a string.
  6. Number(): Converts a value to a number.
  7. Math.random(): Generates a random number between 0 and 1.
  8. Math.round(), Math.floor(), Math.ceil(): Perform rounding and ceiling/floor operations on numbers.
  9. String.length: Returns the length of a string.
  10. Array.isArray(): Checks if a value is an array.
  11. Array.push(), Array.pop(): Adds or removes elements from the end of an array.
  12. Array.join(): Joins all elements of an array into a string.
  13. Array.slice(): Returns a new array containing a portion of the original array.
  14. Date(): Creates a new Date object representing the current date and time.
  15. Date.getTime(): Returns the number of milliseconds since January 1, 1970 (Unix timestamp).
  16. Date.getFullYear(), Date.getMonth(), Date.getDate(): Retrieve specific date components.
  17. setTimeout(), setInterval(): Executes a function after a specified delay or repeatedly at a specified interval.
  18. encodeURIComponent(), decodeURIComponent(): Encodes and decodes URI components.
  19. JSON.parse(), JSON.stringify(): Converts JSON strings to JavaScript objects and vice versa.

These are just a few examples of the built-in functions available in JavaScript. The JavaScript language provides a rich set of functions for various purposes, and you can explore the official JavaScript documentation for a comprehensive list of built-in functions and their usage.

15. What are primitive & non-primitive datatypes?

  1. Primitive Data Types
    Primitive data types form the foundation of JavaScript. They are immutable, which means their values never change once created.

    • Number → represents numeric values (e.g., 5, 3.14).

    • String → represents text enclosed in quotes (e.g., 'Hello', "World").

    • Boolean → represents logical values: true or false.

    • Null → represents the intentional absence of a value (e.g., null).

    • Undefined → appears when a variable is declared but not assigned a value.

    • Symbol → represents unique and immutable identifiers (introduced in ES6).

    When you assign or pass primitive values, JavaScript copies the value. Any change creates a new value instead of modifying the original.

  2. Non-Primitive Data Types (Reference Types)
    Non-primitive data types, also called reference types, store collections or complex structures. They are mutable, which means you can modify their contents.

    • Object → stores key–value pairs (e.g., { name: 'John', age: 30 }).

    • Array → stores ordered collections (e.g., [1, 2, 3], ['apple', 'banana']).

    • Function → defines reusable blocks of code. Functions can be assigned to variables or passed as arguments.

    • Date → represents date and time values.

    • RegExp → defines patterns for string matching and manipulation.

    When you assign or pass non-primitive values, JavaScript passes a reference to the value. Changing the data through that reference also updates the original object.

 

Related Posts

Leave a Reply

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