React.js beginner cards that might be asked in an interview Flashcards
What is React.js?
A JavaScript library for building user interfaces.
True or False: React is a framework.
False
What are components in React?
Reusable pieces of code that return a React element.
Fill in the blank: In React, state is an object that determines the ______ of a component.
data and behavior
What is the purpose of props in React?
To pass data from parent components to child components.
What does JSX stand for?
JavaScript XML
What is a class component?
A component defined as a JavaScript class.
What is a functional component?
A component defined as a JavaScript function.
True or False: React components can be nested.
True
What is the use of the useState hook?
To add state to functional components.
What is the significance of the render method?
In class components, it defines what the UI looks like by returning JSX.
What does the useEffect hook do?
It allows you to perform side effects in functional components.
What is the virtual DOM?
An in-memory representation of the real DOM.
Fill in the blank: The ______ method is called when a component is first added to the DOM.
componentDidMount (for class components) or useEffect with an empty dependency array (for functional components).
What are keys in React?
Unique identifiers for elements in a list.
What is prop drilling?
Passing data through multiple layers of components.
True or False: React uses a one-way data binding.
True
What is a higher-order component?
A function that takes a component and returns a new component.
What is the purpose of the useContext hook?
To access context data in functional components.
What is a controlled component?
A form component where the input value is controlled by React state.
What is the purpose of the shouldComponentUpdate lifecycle method?
In class components, it determines whether a component should re-render. In functional components, use React.memo.
Fill in the blank: React uses ______ to manage the UI updates.
reconciliation
What is the purpose of the useReducer hook?
To manage complex state logic in functional components.
What is the difference between state and props?
State is local and managed within the component, while props are passed from parent to child.
What are fragments in React?
A way to group multiple elements without adding extra nodes to the DOM.
True or False: React can be used for mobile app development.
True