ReactJS Interview Questions

What is React?


  • React is a simple UI API  which uses the component to build an application , uses props to pass data to components and states to maintain data inside the current application.
  • Components should start with capital letters always.

  • Advantages of React

  • React simplifies complex developments like we can create components according to project needs.
  • use of jsx
  • Supports Unidirectional Data Binding
  • React has virtual DOM.
  • Makes application testable
  • Describe React lifecycle?

    Three phases of React lifecycle are Mounting, Updating and Unmounting. Here is a detailed explanation of same in w3Schools.

    What are props in react?

    "Props" is a special keyword in react which stands for properties, using which we can create dynamic components. It is used for passing data between components.

    Also, data can only be transferred from parent to child component and should not be changed by the child component.

    Below is an example code:


    function Hello(props){
    console.log(props);
      return (
        <div>
    <h1>Welcome to React {props.Test}</h1>
    <p>Do something awesome </p>
        </div>
      );
      
    }
    ReactDOM.render(
    <Hello Test = "DeveloperAsks" />,
      document.getElementById('root')
    );

    What is a state in react js?

    The state is a component of React that holds all the information of component and changes as per requirement.

    Difference between state and props in ReactJS?


    • Props are immutable which means it can not be changed, whereas state holds the information, which changes asynchronously.
    • Props are generally set by parent component whereas states get updated by the event handler.



    What is React Fragment?

    React fragment helps us a list of elements or child elements without adding an extra node to DOM. It is a kind of grouping. We can say its a kind of advanced div.

    Syntax for same is <React.Fragment> else only  <> </>, will work.

        <React.Fragment>
    		  <ChildA />
    		  <ChildB />
    		  <ChildC />
    		</React.Fragment>
    	  );

    What are hooks in ReactJS?

    Hooks is a function to add functionality to our Component. Below is an example of some hook states. We can import it as below command.

    import React,{ useState } from 'react';

    What are react profiler?

    Previous
    Next Post »

    Pages