← All topics

React Junior interview questions and answers

75 questions for a React (Junior) interview - with correct answers, explanations and links to the docs.

Take this quiz
  1. 1.What is React?
  2. 2.What is the virtual DOM in React?
  3. 3.What does JSX turn into at build time?
  4. 4.How do you set a CSS class on an element in JSX?
  5. 5.Why can't you write {if (isAdmin) { <Admin /> }} inside JSX?
  6. 6.Why doesn't the component function card() { ... } work as <card />?
  7. 7.How do you return two sibling elements from a component without an extra DOM wrapper?
  8. 8.Can you modify props inside a child component?
  9. 9.How can a child component pass data to its parent?
  10. 10.What is children in React?
  11. 11.What does useState(0) return?
  12. 12.What does console.log print after a click?
  13. 13.What will count be after one click if the initial value is 0?
  14. 14.Why didn't the component re-render?
  15. 15.What's the right way to add an item to an array in state?
  16. 16.Which value is best for key in a list?
  17. 17.What is rendered if items = []?
  18. 18.What's wrong with <button onClick={handleClick()}>?
  19. 19.How do you cancel the default form submission behavior in React?
  20. 20.What is a controlled input?
  21. 21.React warns: "You provided a value prop to a form field without an onChange handler". What happened?
  22. 22.Two sibling components need the same data, which they can change. What should you do first?
  23. 23.What is prop drilling?
  24. 24.When does the effect useEffect(() => { ... }, []) run?
  25. 25.When does an effect without a dependency array run: useEffect(() => { ... })?
  26. 26.When is the function returned from useEffect called?
  27. 27.How does useRef differ from useState?
  28. 28.Which rule of hooks is broken?
  29. 29.Why must a custom hook's name start with use?
  30. 30.When does a child component re-render by default?
  31. 31.How do you set an inline style in JSX?
  32. 32.What steps are needed to pass data via Context?
  33. 33.What does useContext(MyContext) return if there's no provider above the component?
  34. 34.Why does <StrictMode> call render and effects twice in development?
  35. 35.What is React.lazy used for?
  36. 36.What does React.lazy need in order to work?
  37. 37.Why does lazy(() => import('./Chart')) fail if Chart.tsx has only export function Chart?
  38. 38.What's dangerous about dangerouslySetInnerHTML?
  39. 39.How do you attach an app to a DOM element in React 18+?
  40. 40.What is a "pure" component in React terms?
  41. 41.How do you render a list of users from the users array?
  42. 42.What is Redux?
  43. 43.What's required of a reducer in classic Redux (without Immer)?
  44. 44.What does configureStore from Redux Toolkit do?
  45. 45.What are useSelector and useDispatch for?
  46. 46.What does createSlice generate?
  47. 47.What problem does TanStack Query primarily solve?
  48. 48.What must you pass to useQuery?
  49. 49.How do isPending and isFetching differ in TanStack Query v5?
  50. 50.What must you do before using useQuery in an app?
  51. 51.How do you give a prop a default value in a function component?
  52. 52.How do you render one of two elements depending on a condition?
  53. 53.What should a component return to render nothing?
  54. 54.Which attribute links a <label> to an input in JSX?
  55. 55.Why does <img src={url}> without a closing slash fail in JSX?
  56. 56.How do you write a comment inside JSX markup?
  57. 57.When does onChange fire on a text input in React?
  58. 58.How do you pass an argument to a click handler?
  59. 59.How do you stop a click inside a card from also triggering the card's onClick?
  60. 60.Must key values be unique across the whole app?
  61. 61.How do you add a key when each list item renders several elements without a wrapper?
  62. 62.How do you focus an input when a button is clicked?
  63. 63.What does <Button {...props} /> do?
  64. 64.What do {false}, {null}, {undefined} and {0} render in JSX?
  65. 65.What is the naming convention for props that accept event handlers?
  66. 66.How does React recommend reusing UI between components?
  67. 67.How does defaultValue differ from value on an input?
  68. 68.How do you set the selected option of a <select> in React?
  69. 69.Why does this list render nothing?
  70. 70.What is React Developer Tools useful for?
  71. 71.What does the React team recommend for starting a new app today?
  72. 72.Two <Counter /> components are rendered on the page. Do they share state?
  73. 73.Why doesn't clicking <MyButton onClick={save} /> call save?
  74. 74.What type does size have in <Avatar size="40" /> versus <Avatar size={40} />?
  75. 75.What does <input disabled={false} /> render?