React JS
React is a powerful JavaScript library developed by Facebook for building fast and interactive user interfaces, especially single-page applications. It uses a component-based architecture and a virtual DOM to efficiently manage and update the UI. This helps improve performance and makes complex interfaces easier to handle. React is widely used due to its flexibility, speed, and strong community support. It includes features like JSX for writing HTML-like syntax in JavaScript and hooks for managing state and side effects. React also integrates well with other libraries, making it ideal for modern web development.
Take this assessment to check where do you stand in the ReactJS.
Click the Rewards tab for eligibility requirements.
Read the FAQs tab carefully for Instructions before beginning the assessment.
NYXPoints are used to generate the Leaderboard (coming soon). They are awarded for achieving a certain score.
- 200 nyxpoints for a passing score of 80% or more
- 300 nyxpoints for a perfect score of 100%
- Didn’t pass? You still get 30 nyxpoints for attempting the assesment
IMPORTANT instructions for taking the Assessment
- The timer starts when you click Start Assessment
- DO NOT refresh/reload the page or use the back button to navigate away from the page.
- Navigating away from the assessment page DOES NOT stop/pause the timer and the will restart the assessment when you come back to it. The answers are NOT saved.
General
- There are NO pre-requisites to take this assessment. Take this assessment even if you are completely new to Linux.
- The assessment is completely FREE.
- Preferably take it in a closed book mode.
- DO NOT copy/paste, share or upload questions elsewhere.
Eligible Rewards

300 NyxCoins*
* NyxCoins vary on score
Assessment Summary
0 of 30 Questions completed
Questions:
Information
You have already completed the assessment before. Hence you can not start it again.
Assessment is loading…
You must sign in or sign up to start the assessment.
You must first complete the following:
Results
Results
0 of 30 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- Current
- Review
- Answered
- Correct
- Incorrect
-
Question 1 of 30
1. Question
What is the correct way to update state in React when your new state depends on the previous one?
CorrectIncorrect -
Question 2 of 30
2. Question
Which of the following is NOT a valid React Hook in wither React or React Router?
CorrectIncorrect -
Question 3 of 30
3. Question
In React, what is the purpose of keys when rendering lists?
CorrectIncorrect -
Question 4 of 30
4. Question
What is the correct React lifecycle method to make API calls in class components?
CorrectIncorrect -
Question 5 of 30
5. Question
What does the React `StrictMode` component do?
CorrectIncorrect -
Question 6 of 30
6. Question
Which statement about React fragments is true?
CorrectIncorrect -
Question 7 of 30
7. Question
Which hook would you use to run code only when the component mounts and unmounts?
CorrectIncorrect -
Question 8 of 30
8. Question
What is the correct way to pass a prop called “name” to a component?
CorrectIncorrect -
Question 9 of 30
9. Question
What’s the purpose of React context?
CorrectIncorrect -
Question 10 of 30
10. Question
What is the difference between controlled and uncontrolled components?
CorrectIncorrect -
Question 11 of 30
11. Question
When is the best time to use `useMemo` hook?
CorrectIncorrect -
Question 12 of 30
12. Question
What is the purpose of React’s `useCallback` hook?
CorrectIncorrect -
Question 13 of 30
13. Question
What does the term “lifting state up” mean in React?
CorrectIncorrect -
Question 14 of 30
14. Question
What is Virtual DOM in React?
CorrectIncorrect -
Question 15 of 30
15. Question
What is the correct way to conditionally render a component in React?
CorrectIncorrect -
Question 16 of 30
16. Question
What will be logged to the console when the button is clicked?
“`jsx
function Example() {
const [count, setCount] = useState(0);
function handleClick() {
setCount(count + 1);
setCount(count + 1);
console.log(count);
}
return <button onClick={handleClick}>Click me</button>;
}
“`
CorrectIncorrect -
Question 17 of 30
17. Question
What will be rendered by this component?
“`jsx
function Component() {
const [items, setItems] = useState([‘a’, ‘b’, ‘c’]);
return (
<div>
{items.length && <h1>Items: {items.length}</h1>}
</div>
);
}
“`
CorrectIncorrect -
Question 18 of 30
18. Question
What’s wrong with this code?
“`jsx
function Parent() {
const [count, setCount] = useState(0);
function reset() {
setCount(0);
}
return (
<div>
<p>Count: {count}</p>
<Child reset={reset} />
</div>
);
}
function Child({reset}) {
return <button onClick={reset()}>Reset</button>;
}
“`
CorrectIncorrect -
Question 19 of 30
19. Question
After clicking the button, what will be the value of `count`?
“`jsx
function Counter() {
const [count, setCount] = useState(0);
function handleClick() {
setTimeout(() => {
setCount(count + 1);
}, 1000);
setCount(count + 1);
}
return (
<div>
<p>Count: {count}</p>
<button onClick={handleClick}>Increment</button>
</div>
);
}
“`
CorrectIncorrect -
Question 20 of 30
20. Question
What will this component render?
“`jsx
function Example() {
const [state, setState] = useState({name: “John”, age: 30});
function handleClick() {
setState({name: “Jane”});
}
return (
<div>
<p>Name: {state.name}, Age: {state.age}</p>
<button onClick={handleClick}>Update</button>
</div>
);
}
“`
CorrectIncorrect -
Question 21 of 30
21. Question
What will this useEffect do?
“`jsx
function Timer() {
const [count, setCount] = useState(0);
useEffect(() => {
const id = setInterval(() => {
setCount(prev => prev.count = prev.count + 1);
}, 1000);
return () => clearInterval(id);
}, []);
return <div>{count}</div>;
}
“`
CorrectIncorrect -
Question 22 of 30
22. Question
What will be rendered after clicking the button?
“`jsx
function App() {
const [show, setShow] = useState(true);
return (
<div>
<button onClick={() => setShow(!show)}>Toggle</button>
{show && <Child />}
</div>
);
}
function Child() {
useEffect(() => {
return () => console.log(“Cleanup”);
}, []);
return <p>Child component</p>;
}
“`
CorrectIncorrect -
Question 23 of 30
23. Question
What will this code render?
“`jsx
function List() {
const items = [1, 2, 3];
return (
<ul>
{items.map(item => (
<li>{item}</li>
))}
</ul>
);
}
“`
CorrectIncorrect -
Question 24 of 30
24. Question
What will this component render when it first appears on the screen?
“`jsx
function Example() {
const [data, setData] = useState(null);
useEffect(() => {
setData({name: “John”});
}, []);
return <div>{data?.name || “Loading…”}</div>;
}
“`
CorrectIncorrect -
Question 25 of 30
25. Question
What’s wrong with this custom hook?
“`jsx
function useCounter(initialValue) {
const [count, setCount] = useState(initialValue);
function increment() {
setCount(count + 1);
}
return {
count: count,
increment: increment
};
}
“`
CorrectIncorrect -
Question 26 of 30
26. Question
Which of the following statement about the given component is correct?
“`jsx
function Component() {
const [state, setState] = useState({count: 0});
return (
<div>
<p>Count: {state.count}</p>
<button onClick={() => setState(prev => ({count: prev.count + 1}))}>
Increment
</button>
<button onClick={() => setState({})}>Reset</button>
</div>
);
}
“`
CorrectIncorrect -
Question 27 of 30
27. Question
What will happen when this component renders?
“`jsx
function Component({items}) {
const [filteredItems, setFilteredItems] = useState(
items.filter(item => item.active)
);
return (
<ul>
{filteredItems.map(item => (
<li key={item.id}>{item.name}</li>
))}
</ul>
);
}
“`
CorrectIncorrect -
Question 28 of 30
28. Question
What will this code render?
“`jsx
function Parent() {
return (
<div>
<Child />
</div>
);
}
function Child() {
const [count, setCount] = useState(0);
if (count === 0) {
setCount(1);
}
return <div>{count}</div>;
}
“`
CorrectIncorrect -
Question 29 of 30
29. Question
What does this component render?
“`jsx
function Example() {
const items = [‘a’, ‘b’, ‘c’];
const [selected, setSelected] = useState(new Set());
function toggle(item) {
const newSelected = new Set(selected);
if (newSelected.has(item)) {
newSelected.delete(item);
} else {
newSelected.add(item);
}
setSelected(newSelected);
}
return (
<div>
{items.map(item => (
<button
key={item}
style={{color: selected.has(item) ? ‘red’ : ‘black’}}
onClick={() => toggle(item)}
>
{item}
</button>
))}
</div>
);
}
“`
CorrectIncorrect -
Question 30 of 30
30. Question
What will happen when this component renders?
“`jsx
function Example() {
const [state, setState] = useState({count: 0});
useEffect(() => {
setState(prevState => ({
count: prevState.count + 1
}));
}, [state]);
return <div>Count: {state.count}</div>;
}
“`
CorrectIncorrect