wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

React Initial Review

Total questions: 19

Worksheet time: 21mins

Name
Class
Date
1.

What is React?

a)

A programming language used for web development

b)

A javascript library for building user interfaces

c)

A framework for creating mobile applications

d)

A database management system

2.

What is the command to start a react application?

(a)  

Choose from the below words

pnpm create vite

yarn react-app

npm install react-app

npm react-app

3.

What is JSX in React?

a)

Is a JavaScript syntax extension that allows us to mix JS and HTML (XML)

b)

A library of pre-written JavaScript code

c)

A type of JavaScript syntax used to define React components

d)

A programming language used to create web applications

4.

Which of the following is a way to handle data in React.js?

(a)  
Choose from the below words
State & Props
Services & Components
State & CSS
State & Services
5.

What is the method used in the main.tsx page in react to render the elements on the web page?

(a)  

Choose from the below words
render()
createElement()
compile()
mount()
6.

What is the purpose of the useState hook in React?

(a)  
Choose from the below words
To update the state of a component
To handle user events
To access data from an external API
To render elements on the page
7.

What will the useState function return?

a)

A string representing the current state of the component

b)

An object containing the current state and a function to update the state

c)

A function used to update the state

d)

The current state value and a function to update the state

8.

What's the magic formula for using the useState hook?

(a)  

Choose from the below words

useState(value)

UseState(value)

useState[value]

useState[value, setValue]

9.

Can you use useState more than once in a React component?

a)

No, it can only be used once per component

b)

Yes, it can be used multiple times in a component

c)

Can only be used more than once in class components

d)

Depends on the size of the component

10.

Can you use any value to initialize the state of the useState hook?

a)

No, you can only use values of type string

b)

No, you can only use numeric values

c)

Yes, you can use any value

d)

No, you can only use objects

11.

What is the purpose of React Router DOM?

a)

It helps in creating user interfaces.

b)

It is used for routing in React applications

c)

It is used for data fetching in React applications.

d)

It is used for managing state in React applications.

12.

What is the best way to navigate to a new route using React Router?

a)

By manually updating the URL in the address bar.

b)

 By using the <Link> component to create a clickable link to the new route.

c)

By using the history object to push a new route.

d)

By using the <Redirect> component to redirect to the new route.

13.

What is the correct implementation of a Route using React Router DOM?

a)

<Route path="/" element={<Home />} />

b)

<Route path="/" component={<Home />} />

c)

<Route path="/" render={<Home />} />

d)

<Route path="/" element={Home} />

14.

How can you pass props to a component in React?

a)

By using the <props> tag within the component

b)

By using the <passProps> attribute within the component

c)

By passing them as attributes in the component tag

d)

By using the <props> attribute within the component

15.

How do you install React Router DOM?

a)

Using the command "npm or pnpm install react-router-dom"

b)

Downloading it from the official website

c)

Installing it from the React devtools

d)

None of the above

16.

How to declare a new useState?

a)
b)
c)
d)
17.

Which of the following statements is true about using '?' for conditional rendering in React?

a)

You can only use it to render simple expressions, not components

b)

You can use it to conditionally render components or simple expressions

c)

You can only use it to render components, not simple expressions

d)

You cannot use it for conditional rendering in React

18.

How can you use the ? operator to conditionally render one of two components in React?

a)

condition ? <Component1 /> : <Component2 />

b)

<Component1 ? condition : Component2 />

c)

condition && <Component1 /> || <Component2 />

d)

<Component1 || condition ? Component2 />

19.

What is the purpose of useContext hook in React?

a)

To use React's context API to pass data between components

b)

To use React's Redux API to manage state in an application

c)

To use React's Router API to handle navigation in an application

d)

To use React's lifecycle methods in functional components