React Day 03

React Day 03

6th - 8th Grade

22 Qs

quiz-placeholder

Similar activities

HTML Coding <tag> & Style

HTML Coding <tag> & Style

8th - 9th Grade

17 Qs

Cars

Cars

5th Grade - University

17 Qs

Topographic Maps Practice

Topographic Maps Practice

8th - 10th Grade

20 Qs

Vocabulary practice

Vocabulary practice

7th Grade

20 Qs

Systems and Cycles

Systems and Cycles

7th Grade

22 Qs

Review Class

Review Class

6th - 8th Grade

22 Qs

One Step Inequalities

One Step Inequalities

6th - 8th Grade

18 Qs

Inequalities

Inequalities

6th - 8th Grade

20 Qs

React Day 03

React Day 03

Assessment

Quiz

Other

6th - 8th Grade

Easy

Created by

Gnanavel Durairaj

Used 1+ times

FREE Resource

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

Create a free account and access millions of resources

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

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?