Challenge - 5 Problems
React Component Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
What does a React component represent?
In React, what does a component mainly represent?
Attempts:
2 left
💡 Hint
Think about how React builds parts of the screen.
✗ Incorrect
A React component is like a building block of the user interface. It can be reused and can have its own logic and look.
❓ component_behavior
intermediate2:00remaining
What will this React component render?
Given this React component, what will it display on the screen?
React
function Greeting() { return <h1>Hello, friend!</h1>; }
Attempts:
2 left
💡 Hint
Look at the HTML tag used inside the return statement.
✗ Incorrect
The component returns an
element with the text 'Hello, friend!', so it will render a heading with that text.
❓ state_output
advanced2:00remaining
What is the output after clicking the button twice?
Consider this React component. What will be the displayed count after clicking the button two times?
React
import React, { useState } from 'react'; function Counter() { const [count, setCount] = useState(0); return ( <div> <p>Count: {count}</p> <button onClick={() => setCount(count + 1)}>Increase</button> </div> ); }
Attempts:
2 left
💡 Hint
Each click increases the count by 1.
✗ Incorrect
The initial count is 0. Each button click adds 1. After two clicks, count is 2.
📝 Syntax
advanced2:00remaining
Which option correctly defines a React functional component?
Which of the following code snippets correctly defines a React functional component named 'Welcome' that returns a greeting?
Attempts:
2 left
💡 Hint
Remember that a component must return JSX to render.
✗ Incorrect
Option A correctly defines a functional component using an arrow function with an implicit return of JSX.
❓ lifecycle
expert2:00remaining
What happens when the dependency array is empty in useEffect?
In React, what is the behavior of a useEffect hook with an empty dependency array like this?
useEffect(() => {
console.log('Effect ran');
}, []);
Attempts:
2 left
💡 Hint
Think about when React runs effects with no dependencies.
✗ Incorrect
An empty dependency array means the effect runs once after the component appears on screen (mount).