What is React?
Advantages of React
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';
ConversionConversion EmoticonEmoticon