React Day 03

React Day 03

6th - 8th Grade

22 Qs

quiz-placeholder

Similar activities

Adopt Me! Quiz

Adopt Me! Quiz

KG - University

20 Qs

History of Moorestown-Game #2

History of Moorestown-Game #2

KG - 12th Grade

20 Qs

Mes amis, ma vie

Mes amis, ma vie

6th Grade

20 Qs

STRESS

STRESS

7th - 9th Grade

21 Qs

1.6 How do we recycle clothes?

1.6 How do we recycle clothes?

6th Grade

18 Qs

Asas JavaScript

Asas JavaScript

1st Grade - University

18 Qs

Used to - Get used to

Used to - Get used to

7th Grade

20 Qs

BÀI ÔN TẬP TIN HỌC 4

BÀI ÔN TẬP TIN HỌC 4

1st - 9th 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?