DevAcademy
PracticeReactIntermediate

React Intermediate Practice

51 questions covering 17 React topics.

Quick Quiz

1. What does an empty dependency array [] mean for useEffect?

2. What does a function returned from useEffect do?

3. Why is a missing dependency in the dependency array risky?

4. What are the three phases of a component’s lifecycle?

5. Which useEffect pattern corresponds to componentDidMount?

6. What is an advantage of useEffect over separate class lifecycle methods?

7. What does "lifting state up" mean?

8. How does a child component request a change to state that now lives in its parent?

9. What is a sign that lifting state up might not be the best solution anymore?

10. What problem does the Context API solve?

11. Which hook is used to read a context value inside a component?

12. What happens to a context’s consumers when its Provider value changes?

13. Does updating a ref’s .current value trigger a re-render?

14. What is the most common use for a ref attached to a JSX element?

15. Where should you read or write a ref’s value?

16. What naming convention must a custom hook follow?

17. Do two components calling the same custom hook share the same state?

18. What does a custom hook primarily let you reuse?

19. What must every hook’s name start with?

20. Why can’t a hook be called conditionally, e.g. inside an if statement?

21. Where can hooks be called from?

22. What is the key timing difference between useEffect and useLayoutEffect?

23. What problem does useLayoutEffect solve that useEffect cannot?

24. Why should useLayoutEffect be used sparingly?

25. What does useImperativeHandle let a component do?

26. Why is exposing a small custom API often better than exposing the raw DOM node?

27. As of React 19, is forwardRef still required to accept a ref prop?

28. What are the two values returned by useReducer?

29. What does a reducer function receive as arguments?

30. When is useReducer generally preferred over useState?

31. What does useMemo do?

32. What does useCallback memoize?

33. Why is useCallback often paired with React.memo?

34. What does startTransition let you do?

35. What does the isPending flag from useTransition indicate?

36. What happens if the user triggers a new transition while an older one is still processing?

37. What does useDeferredValue return?

38. How does useDeferredValue differ from a fixed-delay debounce?

39. When is useDeferredValue generally preferred over useTransition?

40. What problem does useId solve?

41. Why is Math.random() unsafe for generating an element id?

42. Should useId be used to generate keys for a list of rendered items?

43. What kind of data source is useSyncExternalStore designed for?

44. What does the getSnapshot function need to return?

45. Why is useSyncExternalStore preferred over a manual useEffect + useState subscription for external stores?

46. What does useDebugValue affect?

47. Why is useDebugValue mainly useful for custom hooks specifically?

48. What is the purpose of the optional second argument to useDebugValue?

49. What does an error boundary do?

50. Can an error boundary currently be written as a function component with hooks?

51. Does an error boundary catch errors thrown inside an onClick event handler?