React JSX Quiz

Test your React JSX understanding by taking this quiz

React Quiz #01 - React JSX Complete Guide

5 mins read

1. Which is the correct way to add comments in JSX?

2. What will be the output of this JSX code?

 const name = "Alice";
const element = <h1>Hello, {name}</h1>;

3. What will be the output of this JSX?

 const element = (
<>
<h1>{1 + 1}</h1>
<p>{true ? "Yes" : "No"}</p>
<p>{null}</p>
<p>{undefined}</p>
</>
);

4. What is the purpose of the “dangerouslySetInnerHTML” prop in React JSX?

5. What will be the output of this JSX?

 const element = <input value="React" onChange={() => {}} />; 

6. What is the correct way to conditionally render elements in JSX?

7. What will be the output of this JSX?

 const numbers = [1, 2, 3];
const element = (
<ul>
{numbers.map((number) => (
<li>{number}</li>
))}
</ul>
);

8. How do you access the value of an input field in React JSX?

9. What will be the JSX based on the “condition”?

 const condition = false;
const element = (
<div>
{condition ? <p>Condition is true</p> : <p>Condition is false</p>}
</div>
);

10. What is the purpose of the “className” prop in React JSX?