React Day 03

React Day 03

6th - 8th Grade

22 Qs

quiz-placeholder

Similar activities

ASK - 4.2 HTML

ASK - 4.2 HTML

7th - 10th Grade

19 Qs

Stoichimetry Quiz

Stoichimetry Quiz

6th - 12th Grade

20 Qs

Music of Mindanao

Music of Mindanao

7th Grade

20 Qs

Burger

Burger

1st - 12th Grade

20 Qs

ULANGAN HARIAN BAHASA SUNDA KE 2/6SD

ULANGAN HARIAN BAHASA SUNDA KE 2/6SD

6th Grade

20 Qs

Effect of force and pressure

Effect of force and pressure

7th Grade

17 Qs

THE SPANISH ERA

THE SPANISH ERA

4th Grade - University

20 Qs

PROPER CARE OF CLOTHES PART II (True or False)

PROPER CARE OF CLOTHES PART II (True or False)

6th Grade

20 Qs

React Day 03

React Day 03

Assessment

Quiz

Other

6th - 8th Grade

Practice Problem

Easy

Created by

Gnanavel Durairaj

Used 1+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

22 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can we update state based on the previous state?

setState(count + 1);

setState((prev) => prev + 1);

setState(() => count + 1);

setState = count + 1;

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

When does useEffect run if the dependency array is empty ([])?

Every render

Only once after the initial render

When the component is unmountedNever

Never

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will happen in this code?

useEffect(() => {

console.log("Effect ran!");

}, []);

Logs "Effect ran!" on every render

Logs "Effect ran!" once after mounting

Throws an error

Does not execute

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you clean up effects in useEffect?

useEffect(() => {

const interval = setInterval(() => {

console.log("Hello");

}, 1000);

return () => clearInterval(interval);

}, []);

useCleanup()

Using return () => {} inside useEffect

componentWillUnmount()

No cleanup needed

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the main purpose of useContext?

To create state in a component

To fetch data from an API

To manage global state without prop drilling

To handle lifecycle methods

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct way to consume context inside a component?

const MyContext = createContext("default");

const value = ???

useContext(MyContext);

<MyContext.Consumer>

MyContext.Provider

useState(MyContext);

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is required when using useContext?

A state variable

A reducer

A provider component

Nothing, it works standalone

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?