import React.Component from 'react'import [ Component ] from 'react'import Component from 'react'import { Component } from 'react' <<<<<--CORRECTReact.memo higher-order component. <<<<<--CORRECTuseReducer Hook.useMemo Hook.shouldComponentUpdate lifecycle method.const person =(firstName, lastName) => { first: firstName, last: lastName } console.log(person("Jill", "Wolson"))
import React, {useState} from 'react';
const name = 'Rachel'; const age = 31; const person = { name, age }; console.log(person);
{{name: "Rachel", age: 31}}{name: "Rachel", age: 31} <<<<<--CORRECT{person: "Rachel", person: 31}}{person: {name: "Rachel", age: 31}}const topics = ['cooking', 'art', 'history'];
const first = ["cooking", "art", "history"]const [] = ["cooking", "art", "history"]const [, first]["cooking", "art", "history"]const [first] = ["cooking", "art", "history"] <<<<<--CORRECTconst [, , animal] = ['Horse', 'Mouse', 'Cat']; console.log(animal);
<Message {...props} />
<Route path="/:id" />
function Dish() { return <h1> Mac and Cheese</h1>; } ReactDOM.render(<Dish />, document.getElementById('root'));
divh1 <<<<<--CORRECTReact.createElement('h1', null, "What's happening?");
<h1 props={null}>What's happening?</h1><h1>What's happening?</h1> <<<<<--CORRECT<h1 id="component">What's happening?</h1><h1 id="element">What's happening?</h1>function MyComponent() { return ( <Suspense> <div> <Message /> </div> </Suspense> ); }
let message = 'Hi there'; const element = <p>{message}</p>;
React.memoReact.splitReact.lazy <<<<<--CORRECTReact.fallbackA. <button onClick="{this.handleClick}>Click Me</button>" B. <button onClick="{event => this.handleClick(event)}}>Click Me</button>"
function Dish(props) { return ( <h1> {props.name} {props.cookingTime} </h1> ); }
function Dish([name, cookingTime]) { return <h1>{name} {cookingTime}</h1>; }
function Dish({name, cookingTime}) { return <h1>{name} {cookingTime}</h1>; } <<<<<--CORRECT
function Dish(props) { return <h1>{name} {cookingTime}</h1>; }
function Dish(...props) { return <h1>{name} {cookingTime}</h1>; }
const Heading = () => { <h1>Hello!</h1>; };
[e.target.id] called in the following code snippet?handleChange(e) { this.setState({[e.target.id]: e.target.value }) }
class Clock extends React.Component {
render() {
return <h1>Look at the time: {time}</h1>;
}
}
ReactReactDOM <<<<<--CORRECTRenderDOMvalue propertydefaultValue property <<<<<--CORRECTdefault propertyclass clock extends React.Component { render() { return <h1>Look at the time: {this.props.time}</h1>; } }
thisclock <<<<<--CORRECT (In JSX, lower-case tag names are considered to be HTML tags. Read this article)useEffect(function updateTitle() { document.title = name + ' ' + lastname; }); <<<<<--CORRECTuseEffect(() => { title = name + ' ' + lastname; });useEffect(function updateTitle() { name + ' ' + lastname; });useEffect(function updateTitle() { title = name + ' ' + lastname; });React.fallbackReact.splitReact.lazy <<<<<--CORRECTReact.memofunction MyComponent(props) { const [done, setDone] = useState(false); return <h1>Done: {done}</h1>; }
useEffect(() => { setDone(true); });useEffect(() => { setDone(true); }, []);useEffect(() => { setDone(true); }, [setDone]); <<<<<--CORRECTuseEffect(() => { setDone(true); }, [done, setDone]);What value of button will allow you to pass the name of the person to be hugged?
class Huggable extends React.Component{ hug(id){ console.log("hugging " + id); } render() { let name = "kitteh"; let button = // Missing Code return button; } }
<button onClick={(name) => this.hug(name)>Hug Button</button><<<<<--CORRECT<button onClick={this.hug(e, name)}>Hug Button</button><button onClick={(e) => hug(e,name)}>Hug Button</button><button onClick={(e) => this.hug(name, e)}>Hug Button</button>Currently, handleClick is being called instead of passed as a reference. How do you fix this?
<button onClick={this.handleClick()}>Click this</button>
<button onClick={this.handleClick.bind(handleClick}>Click this</button><<<<<--CORRECT<button onClick={handleClick()}>Click this</button><button onClick={this.handleClick}>Click this</button><button onclick={this.handleClick}>Click this</button>