React & TypeScript
26 questions · 5 output questions · 5 challenges · 3 mocks
React Fundamentals
Components and props
What is a component in React and what are props?
State vs props
What is the difference between state and props in React?
What is JSX?
What is JSX and how does it differ from HTML?
Lists and keys
What are keys for when you render a list in React, and why isn't using the index recommended?
What is React?
What is React and what problem does it solve?
Rendering and re-renders
When does a component re-render in React?
Hooks
Custom hooks: reusing stateful logic
What is a custom hook and when would you create one? Do two components that use the same custom hook share state?
Rules of hooks
What are the rules of hooks and why do they exist? What happens if I call a hook inside an if?
useEffect: side effects and cleanup
What is useEffect for and when does it run? What's the difference between passing `[]`, passing dependencies, or not passing an array?
useMemo and useCallback: memoization and referential equality
What are useMemo and useCallback for? When would you use them and when would they be a premature optimization?
useRef: mutable values and DOM references
What is useRef and how is it different from useState?
useState: state in function components
How does useState work? If I call the set function, does the value change immediately?
TypeScript Fundamentals
any vs unknown vs never
What is the difference between `any`, `unknown`, and `never`? When would you use each one?
Generics
What are generics in TypeScript and what are they for?
Interface vs type
What is the difference between `interface` and `type` in TypeScript? Which one do you use and why?
Basic types and inference
What does TypeScript add over JavaScript, and how does type inference work?
Union types and narrowing
What is a union type and what is narrowing in TypeScript?
Utility types
Which TypeScript utility types do you know and what are they for?
React with TypeScript
Children and composition
How do you type `children` in a component and what is composition for in React?
Typing state and hooks
How do you type `useState` in TypeScript? Do you always have to pass it the type?
Typing events in React
How do you type events in React with TypeScript? For example, the `onChange` of an input or the `onSubmit` of a form.
Typing a component's props
How do you type a component's props in React with TypeScript?
State & Patterns
Context and prop drilling
What is prop drilling and how does Context solve it?
useReducer
When would you use `useReducer` instead of `useState`?
Lifting state up
What does "lifting state up" mean in React and in what situation would you do it?
Controlled vs uncontrolled components
What is the difference between a controlled and an uncontrolled component in React?
Coding challenges
What does this code print?
What does it print? #001
numeric and string enums, ?? vs ||, optional chaining.
What does it print? #002
types are erased at runtime, narrowing with typeof,
What does it print? #003
parent → child render order, what <StrictMode> does in development.
What does it print? #004
state doesn't change immediately, batching, functional form of setState.
What does it print? #005
render vs effect, cleanup, useEffect dependency array.