React interview Flashcards
Common tech questions for react/typescript positions (32 cards)
What is React?
A JavaScript library for building user interfaces.
True or False: React uses a virtual DOM.
True
What are components in React?
Reusable pieces of UI that can be defined as classes or functions.
Fill in the blank: In React, a component’s state is managed using the ______ hook.
useState
What is JSX?
A syntax extension for JavaScript that looks similar to XML or HTML.
What is the purpose of the useEffect hook?
To perform side effects in function components.
What does props stand for in React?
Properties, which are used to pass data from parent to child components.
True or False: React components must return a single root element.
True
What is the difference between state and props?
State is managed within a component, while props are passed from parent to child components.
What is a higher-order component (HOC)?
A function that takes a component and returns a new component.
Fill in the blank: In React, the ______ method is used to update the component’s state.
setState
What is the purpose of the React Router?
To enable navigation between different components in a React application.
What are controlled components in React?
Components that derive their form data from the component’s state.
What is TypeScript?
A superset of JavaScript that adds static type definitions.
True or False: TypeScript can be used with React applications.
True
What is the purpose of interfaces in TypeScript?
To define the shape of an object.
What does the ‘any’ type in TypeScript signify?
It allows a variable to hold any type of value.
Fill in the blank: In TypeScript, you can define a type using the ______ keyword.
type
What is the use of the ‘key’ prop in React?
To uniquely identify elements in a list for efficient updates.
What is the significance of the useRef hook?
It allows you to create mutable references to DOM elements.
What is the difference between class components and functional components?
Class components are ES6 classes, while functional components are plain JavaScript functions.
True or False: React.StrictMode is used to highlight potential problems in an application.
True
What is the purpose of the Context API in React?
To provide a way to pass data through the component tree without passing props manually at every level.
Fill in the blank: You can manage global state in React using the ______ hook.
useContext