React and Typescript Flashcards
(50 cards)
What is React?
A JavaScript library for building user interfaces using a component-based architecture.
What is a React component?
A reusable piece of UI defined as a function or class.
What are props in React?
Inputs passed from parent to child components to configure behavior or appearance.
What is state in React?
A component-specific object that determines how a component behaves and renders.
What is JSX?
A syntax extension for JavaScript that allows writing HTML-like code in React.
What is the virtual DOM?
A lightweight in-memory representation of the real DOM used to optimize rendering.
What is the useEffect hook?
A hook for handling side effects like data fetching or subscriptions.
What is the useState hook?
A hook that adds state management to functional components.
What is the purpose of React keys?
To help React identify which items changed, added, or removed in a list.
What is React Router?
A library for routing in React applications, enabling dynamic navigation.
What is the useRef hook?
A hook that provides a mutable reference that persists across renders.
What is the useCallback hook?
Returns a memoized version of a callback function.
What is the useMemo hook?
Memoizes the result of a computation to avoid unnecessary recalculations.
What is context in React?
A way to share data across components without using props.
What is the useContext hook?
Allows consuming context values in functional components.
What is a custom hook?
A reusable function that uses built-in hooks and starts with ‘use’.
What is a controlled component?
A component whose input form elements are controlled by state.
What is an uncontrolled component?
A component that manages its own internal state using refs.
What is React.memo?
A higher-order component that memoizes the result to prevent re-rendering.
What is the useReducer hook?
A hook for managing complex state logic with reducers.
What is TypeScript?
A superset of JavaScript that adds static typing.
Why use TypeScript with React?
To catch errors during development, improve code clarity, and enable powerful IDE support.
How do you type React props?
By defining an interface and passing it as a generic to the component.
How do you type component state in TypeScript?
By using type annotations with useState or interfaces in class components.