DEV Community

Cover image for 10 ReactJS quizzes
Dovud Husanov
Dovud Husanov

Posted on • Edited on

10 ReactJS quizzes

If you want to import just the Component from the React library, what syntax do you use?

☑️ import React.Component from 'react'
☑️ import [ Component ] from 'react'
☑️ import Component from 'react'
import { Component } from 'react'

If a function component should always render the

same way given the same props, what is a simple performance optimization available for it?

✅ Wrap it in the React.memo higher-order component.
☑️ Implement the useReducer Hook.
☑️ Implement the useMemo Hook.
☑️ Implement the shouldComponentUpdate lifecycle method.

How do you fix the syntax error that results from running this code?

const person =(firstName, lastName) =>
{
first: firstName,
last: lastName
}
console.log(person("Jill", "Wilson"))

✅ Wrap the object in parentheses.
☑️ Call the function from another file.
☑️ Add a return statement before the first curly brace.
☑️ Replace the object with an array.

If you see the following import in a file, what is being used for state management in the component?

import React, {useState} from 'react';

✅ React Hooks
☑️ stateful components
☑️ math
☑️ class components

Using object literal enhancement, you can put values back into an object. When you log person to the console, what is the output?

const name = 'Rachel';
const age = 31;
const person = { name, age };
console.log(person);

☑️ {{name: "Rachel", age: 31}}
{name: "Rachel", age: 31}
☑️ {person: "Rachel", person: 31}}
☑️ {person: {name: "Rachel", age: 31}}

What is the testing library most often associated with React?

☑️ Mocha
☑️ Chai
☑️ Sinon
✅ Jest

To get the first item from the array ("cooking") using array destructuring, how do you adjust this line?

const topics = ['cooking', 'art', 'history'];

☑️ const first = ["cooking", "art", "history"]
☑️ const [] = ["cooking", "art", "history"]
☑️ const [, first]["cooking", "art", "history"]
const [first] = ["cooking", "art", "history"]

How do you handle passing through the component tree without having to pass props down manually at every level?

☑️ React Send
☑️ React Pinpoint
☑️ React Router
✅ React Context

What should the console read when the following code is run?

const [, , animal] = ['Horse', 'Mouse', 'Cat'];
console.log(animal);

☑️ Horse
✅ Cat
☑️ Mouse
☑️ undefined

What is the name of the tool used to take JSX and turn it into

createElement calls?

☑️ JSX Editor
☑️ ReactDOM
☑️ Browser Buddy
✅ Babel

https://dovudhon.com
https://github.com/dovudhonhusanov

Top comments (1)

Collapse
 
sardordaminov profile image
Sardordaminov

nice