All React quizzes
Beginner30 questions30 minutes

React Beginner Quiz

JSX, props, state and events — the basics, checked by reading real components rather than reciting definitions.

Start the quiz

Sample questions from this quiz

A preview of the style and depth. Try each one, then reveal the answer — or skip straight to the timed quiz.

1. What renders?

function Greeting() {
  const name = 'Sam'
  return <h1>Hello, {name}!</h1>
}
  • An error
  • Hello, {name}!
  • Hello, !
  • Hello, Sam!
Show answer

Answer: Hello, Sam!. Curly braces embed a JavaScript expression in JSX, so `{name}` is evaluated rather than printed literally. Anything that produces a value works there — a variable, a function call, a ternary — but statements like `if` do not.

2. This fails to compile. Which line is wrong?

1  function Card() {
2    return (
3      <h2>Title</h2>
4      <p>Body</p>
5    )
6  }
  • Line 2 — the parentheses are invalid
  • Lines 3-4 — a component must return a single root element
  • Line 4 — <p> cannot follow <h2>
  • Line 1 — the component needs props
Show answer

Answer: Lines 3-4 — a component must return a single root element. JSX compiles to a single expression, so sibling elements need a wrapper. Use a `<div>`, or a Fragment (`<>...</>`) when you do not want an extra DOM node — inside a table or a flex container an extra div would break the layout.

3. What does the child render?

function App() {
  return <Hello name="Ali" age={30} />
}
function Hello({ name, age }) {
  return <p>{name} is {age}</p>
}
  • Ali is 30
  • name is age
  • Ali is {30}
  • An error — props must be strings
Show answer

Answer: Ali is 30. Props pass data from parent to child. Strings use quotes; anything else — numbers, booleans, arrays, functions — goes in braces. Destructuring in the parameter list is the usual way to read them.

Frequently asked questions

How many questions are in this React quiz?+

30 questions, with a 30-minute time limit. Every question includes a written explanation of the correct answer.

Is this React quiz free?+

Yes. Every quiz on CodexQuizz is free and needs no account. You only enter a name if you choose to post your score to the leaderboard.

What level is the beginner quiz aimed at?+

JSX, props, state and events — the basics, checked by reading real components rather than reciting definitions.

Can I use this to prepare for a React interview?+

Yes. The questions cover the topics that come up in React technical screens, and the explanations are written so that a wrong answer still teaches you the underlying concept.

Ready to test your React?

30 questions, 30 minutes. Free, no sign-up.

Start now