React Online Question

What is the correct command to create a new React project? (A) npm create-react-app (B) npx create-react-app myReactApp (C) npm create-react-app myReactApp (D) npx create-react-app

What does myReactApp refer to in the following command? npx create-react-app myReactApp (A) The directory to create the new app in (B) A reference to an existing app (C) The name you want to use for the new app (D) The type of app to create

What command is used to start the React local development server? (A) npm serve (B) npm start (C) npm build (D) npm run dev

What is the default local host port that a React development server uses? (A) 3000 (B) 3500 (C) 8080 (D) 5000

To develop and run React code, Node.js is required. (A) True (B) False

What type of element will be rendered from the following code? function Car() { return <h1>Ford Mustang</h1>; } ReactDOM.render(<Car />, document.getElementById('root')); (A) div (B) ReactDom (C) h1 (D) Component

What is the children prop? (A) A property that lets you pass data to child components (B) A property that adds child values to state (C) A property that lets you nest components in other components (D) A property that lets you set an object as a property

Which keyword creates a constant in JavaScript? (A) var (B) constant (C) const (D) let

A copy of the 'real' DOM that is kept in memory is called what? (A) React DOM (B) Virtual DOM (C) DOM (D) Shadow DOM

React component names must begin with an uppercase letter. (A) True (B) False

React Online Question

Which operator can be used to conditionally render a React component? (A) || (B) ?? (C) && (D) ::

When rendering a list using the JavaScript map() method, what is required for each element rendered? (A) key (B) index (C) id (D) data

What tool does React use to compile JSX? (A) Babel (B) React Router (C) ReactDOM (D) JSX Compiler

How can you optimze performance for a function component that always renders the same way? (A) Wrap it in the React.memo higher-order component. (B) Use the shouldComponentUpdate lifecycle method. (C) Use the useMemo Hook. (D) Use the useReducer Hook.

What props will be available to the following component? <Car {...props} /> (A) only updated ones (B) only static ones (C) all of them (D) children

What is a common use case for ref? (A) To directly access a DOM node (B) To bind the function (C) To refer to another JavaScript file (D) To refer to a function

How can you combine the following arrays using the spread operator? const array1 = [1, 2, 3]; const array2 = [4, 5, 6]; (A) const combined = ...array1 + ...array2; (B) const combined = [array1, array2]; (C) const combined = [...array1, ...array2]; (D) const combined = array1 + array2;

React can only render elements in the root document element. (A) False (B) True

What is the correct syntax to import a Component from React? (A) import { Component } from 'react' (B) import Component from 'react' (C) import React.Component from 'react' (D) import [ Component ] from 'react'

Find the bug in this code: function car({make, model}) { return <h1>{make} {model}</h1>; }; (A) Remove the return statement (B) Add parenthesis around the return value (C) Wrap the return in a fragment (D) The first letter of the function must be capitalized

React Online Question

React separates the user interface into components. How are components combinded to create a user interface? (A) With webpack (B) By putting them in a folder structure (C) By nesting components (D) With code splitting

Although React Hooks generally replace class components, there are no plans to remove classes from React. (A) True (B) False

Which of the following is NOT a rule for React Hooks? (A) Hooks cannot be conditional (B) Hooks can only be called inside React Function components (C) Hooks can only be called at the top level of a component (D) Hooks can be called in Class or Function components

What is the output of the following code? const make = 'Ford'; const model = 'Mustang'; const car = { make, model }; console.log(car); (A) {{make: 'Ford', model: 'Mustang'}} (B) {make: 'Ford', model: 'Mustang'} (C) {car: {make: 'Ford', model: 'Mustang'}} (D) {car: 'Ford', car: 'Mustang'}}

Why should you avoid copying the values of props into a component's state? (A) Because prop values cannot be stored in state (B) Because that would create two instances of the same state that could become out of sync (C) Because you should never mutate state (D) Because you want to allow data to flow back up to the parent