React Interview Questions Tutorial
React.js Beginner level interview question
Q. What is React?
A. React is a web front-end development framework written in Javascript. It was developed by Facebook in 2011. It is open source and it's still one of the top front-end web development technology in 2021.
Q. What is JSX?
A. JSX stand for JavaScript Extended. JSX is extended form of JavaScript designed by facebook, in a way that it allows developer to write JavaScript expression and HTML tags at the same place, and it is smart enough to seperate them and render them correctly on Browser.
Q. Can we have multiple root in React application?
A. Yes, we have have multiple root in react application. CRA (Create React App) generally consist of only one root, but applications that uses react js as script link (as in <script src=""), they have multiple roots, it depends on project requirement.
Q. How can you pass data between different components?
A. We can use props for this purpose. Other ways are to use thrid party store management services like Redux, MobX, or in newer versions of React we can use Context API.
Q. What is different between Pure and Impure component?
A. Pure components are those, who do not change the value of props. Impure components are those components who try to change the props value.
// Pure function
function MyPureComponent = (props) => {
return <>Num is: {props.NumOne + props.NumTwo}</>;
}
// Impure function
function MyImPureComponent = (props) => {
props.NumOne += props.NumTwo;
return <>Num is: {props.NumOne}</>;
}