\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is all of them"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"any that have not changed","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"child props","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"any that have changed","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"all of them","comment":{"@type":"Comment","text":"Option B is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### Consider the following code from React Router. What do you call :id in the path prop?\n\n```javascript\n\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is This is a route parameter"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"This is a route modal","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"This is a route splitter","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"This is a route link","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"This is a route parameter","comment":{"@type":"Comment","text":"Option B is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### If you created a component called Dish and rendered it to the DOM, what type of element would be rendered?\n\n```javascript\nfunction Dish() {\n return
Mac and Cheese
;\n}\n\nReactDOM.render(, document.getElementById('root'));\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is `h1`"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"`div`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"section","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"component","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":3,"encodingFormat":"text/markdown","text":"`h1`","comment":{"@type":"Comment","text":"Option D is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### What does this React element look like given the following code? (Alternative: Given the following code, what does this React element look like?)\n\n```javascript\nReact.createElement('h1', null, \"What's happening?\");\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is `
`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"`
What's happening?
`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"`
What's happening?
`","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"`
What's happening?
`","comment":{"@type":"Comment","text":"Option B is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### What property do you need to add to the Suspense component in order to display a spinner or loading state?\n\n```javascript\nfunction MyComponent() {\n return (\n \n
\n \n
\n \n );\n}\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is fallback"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"lazy","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"loading","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"spinner","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"fallback","comment":{"@type":"Comment","text":"Option C is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### How would you describe the message variable wrapped in curly braces below?\n\n```javascript\nconst message = 'Hi there';\nconst element =
{message}
;\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is a JS expression"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"a JS function","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"a JS element","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"a JSX wrapper","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"a JS expression","comment":{"@type":"Comment","text":"Option C is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"What can you use to handle code splitting?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is `React.lazy`"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"`React.memo`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"`React.split`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"`React.fallback`","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"`React.lazy`","comment":{"@type":"Comment","text":"Option C is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"When do you use `useLayoutEffect`?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is to change the layout of the screen"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"to optimize for all devices","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"to complete the update","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"when you need the browser to paint before the effect runs","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"to change the layout of the screen","comment":{"@type":"Comment","text":"Option C is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### What is the difference between the click behaviors of these two buttons (assuming that this.handleClick is bound correctly)?\n\n```javascript\nA. \nB. \n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is There is no difference."},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"Button A will not have access to the event object on click of the button.","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"Button B will not fire the handler this.handleClick successfully.","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"Button A will not fire the handler this.handleClick successfully.","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":3,"encodingFormat":"text/markdown","text":"There is no difference.","comment":{"@type":"Comment","text":"Option D is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### How do you destructure the properties that are sent to the Dish component?\n\n```javascript\nfunction Dish(props) {\n return (\n
\n {props.name} {props.cookingTime}\n
\n );\n}\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is `function Dish({name, cookingTime}) { return
; }`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"`function Dish(props) { return
{name} {cookingTime}
; }`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"`function Dish(...props) { return
{name} {cookingTime}
; }`","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"`function Dish({name, cookingTime}) { return
{name} {cookingTime}
; }`","comment":{"@type":"Comment","text":"Option B is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"When might you use `React.PureComponent`?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is when you want a default implementation of `shouldComponentUpdate()`"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"when you do not want your component to have props","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"when you have sibling components that need to be compared","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"when you do not want your component to have state","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"when you want a default implementation of `shouldComponentUpdate()`","comment":{"@type":"Comment","text":"Option C is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"Why is it important to avoid copying the values of props into a component's state where possible?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is because you want to allow a component to update in response to changes in the props"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"because you should never mutate state","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"because `getDerivedStateFromProps()` is an unsafe method to use","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"because you want to allow data to flow back up to the parent","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"because you want to allow a component to update in response to changes in the props","comment":{"@type":"Comment","text":"Option C is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"What is the children prop?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is a special property that JSX creates on components that contain both an opening tag and a closing tag, referencing it's contents."},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"a property that adds child components to state","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"a property that lets you set an array as a property","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"a property that lets you pass data to child elements","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"a special property that JSX creates on components that contain both an opening tag and a closing tag, referencing it's contents.","comment":{"@type":"Comment","text":"Option B is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"Which attribute is React's replacement for using innerHTML in the browser DOM?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is dangerouslySetInnerHTML"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"injectHTML","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"weirdSetInnerHTML","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"strangeHTML","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"dangerouslySetInnerHTML","comment":{"@type":"Comment","text":"Option B is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"Which of these terms commonly describe React applications?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is declarative"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"integrated","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"closed","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"imperative","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"declarative","comment":{"@type":"Comment","text":"Option A is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"When using webpack, why would you need to use a loader?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is to preprocess files"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"to put together physical file folders","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"to load external data","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"to load the website into everyone's phone","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"to preprocess files","comment":{"@type":"Comment","text":"Option B is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"A representation of a user interface that is kept in memory and is synced with the \"real\" DOM is called what?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is virtual DOM"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"DOM","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"virtual elements","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"shadow DOM","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"virtual DOM","comment":{"@type":"Comment","text":"Option A is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### You have written the following code but nothing is rendering. How do you fix this problem?\n\n```javascript\nconst Heading = () => {\n
Hello!
;\n};\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is Change the curly braces to parentheses or add a return statement before the `h1` tag."},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"Add a render function.","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"Move the `h1` to another component.","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"Surround the `h1` in a `div`.","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"Change the curly braces to parentheses or add a return statement before the `h1` tag.","comment":{"@type":"Comment","text":"Option B is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"To create a constant in JavaScript, which keyword do you use?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is const"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"let","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"constant","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"var","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"const","comment":{"@type":"Comment","text":"Option A is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"What do you call a React component that catches JavaScript errors anywhere in the child component tree?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is error boundaries"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"error bosses","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"error catchers","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"error helpers","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":3,"encodingFormat":"text/markdown","text":"error boundaries","comment":{"@type":"Comment","text":"Option D is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"In which lifecycle method do you make requests for data in a class component?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is componentDidMount"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"constructor","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"componentWillReceiveProps","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"componentWillMount","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"componentDidMount","comment":{"@type":"Comment","text":"Option B is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"React components are composed to create a user interface. How are components composed?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is by nesting components"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"by putting them in the same file","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"with webpack","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"with code splitting","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"by nesting components","comment":{"@type":"Comment","text":"Option B is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"All React components must act like **\\_** with respect to their props.","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is pure functions"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"monads","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"recursive functions","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"higher-order functions","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"pure functions","comment":{"@type":"Comment","text":"Option B is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### What is `[e.target.id]` called in this code snippet?\n\n```javascript\nconst handleChange = (e) => {\n setState((prevState) => ({ ...prevState, [e.target.id]: e.target.value }));\n};\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is a dynamic key"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"a computed property name","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"a set value","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"a JSX code string","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"a dynamic key","comment":{"@type":"Comment","text":"Option C is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### What is the name of this component?\n\n```javascript\nclass Clock extends React.Component {\n render() {\n return
Look at the time: {time}
;\n }\n}\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is Clock"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"It does not have a name prop.","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"React.Component","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"Component","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"Clock","comment":{"@type":"Comment","text":"Option A is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"What is sent to an `Array.map()` function?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is a callback function that is called once for each element in the array"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"the name of another array to iterate over","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"the number of times you want to call the function","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"a string describing what the function should do","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"a callback function that is called once for each element in the array","comment":{"@type":"Comment","text":"Option A is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"Why is it a good idea to pass a function to `setState` instead of an object?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is `setState` is asynchronous and might result in out of sync values."},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"It provides better encapsulation.","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"It makes sure that the object is not mutated.","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"It automatically updates a component.","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":3,"encodingFormat":"text/markdown","text":"`setState` is asynchronous and might result in out of sync values.","comment":{"@type":"Comment","text":"Option D is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"What package contains the render() function that renders a React element tree to the DOM?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is `ReactDOM`"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"`React`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"`Render`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"`DOM`","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"`ReactDOM`","comment":{"@type":"Comment","text":"Option B is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"How do you set a default value for an uncontrolled form field?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is Use the `defaultValue` property."},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"Use the `value` property.","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"Use the `default` property.","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"It assigns one automatically.","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"Use the `defaultValue` property.","comment":{"@type":"Comment","text":"Option B is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### What do you need to change about this code to get this code to run?\n\n```js\nconst clock = (props) => {\n return
Look at the time: {props.time}
;\n};\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is Capitalize `clock`"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"Add quotes around the return value","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"Remove `this`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"Remove the render method","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":3,"encodingFormat":"text/markdown","text":"Capitalize `clock`","comment":{"@type":"Comment","text":"Option D is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"Which Hook could be used to update the document's title?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is `useEffect(function updateTitle() { document.title = name + ' ' + lastname; });`"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"`useEffect(() => { title = name + ' ' + lastname; });`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"`useEffect(function updateTitle() { name + ' ' + lastname; });`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"`useEffect(function updateTitle() { title = name + ' ' + lastname; });`","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"`useEffect(function updateTitle() { document.title = name + ' ' + lastname; });`","comment":{"@type":"Comment","text":"Option A is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"Which function from React can you use to wrap Component imports to load them lazily?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is `lazy`"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"`fallback`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"`split`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"`memo`","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"`lazy`","comment":{"@type":"Comment","text":"Option C is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### How do you invoke setDone only when component mounts, using hooks?\n\n```javascript\nfunction MyComponent(props) {\n const [done, setDone] = useState(false);\n\n return
Done: {done}
;\n}\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is `useEffect(() => { setDone(true); }, []);`"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"`useEffect(() => { setDone(true); });`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"`useEffect(() => { setDone(true); }, [setDone]);`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"`useEffect(() => { setDone(true); }, [done, setDone]);`","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"`useEffect(() => { setDone(true); }, []);`","comment":{"@type":"Comment","text":"Option B is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### Currently, `handleClick` is being called instead of passed as a reference. How do you fix this?\n\n```javascript\n\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is ``"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"``","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"``","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"``","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"``","comment":{"@type":"Comment","text":"Option C is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"Which answer best describes a function component?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is A function component accepts a single props object and returns a React element."},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"A function component is the same as a class component.","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"A function component is the only way to create a component.","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"A function component is required to create a React component.","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"A function component accepts a single props object and returns a React element.","comment":{"@type":"Comment","text":"Option B is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"Which library does the `fetch()` function come from?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is No library. `fetch()` is supported by most browsers."},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"FetchJS","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"ReactDOM","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"React","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"No library. `fetch()` is supported by most browsers.","comment":{"@type":"Comment","text":"Option C is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### What will happen when this useEffect Hook is executed, assuming name is not already equal to John?\n\n```javascript\nuseEffect(() => {\n setName('John');\n}, [name]);\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is It will update the value of name once and not run again until name is changed from the outside."},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"It will cause an error immediately.","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"It will execute the code inside the function, but only after waiting to ensure that no other component is accessing the name variable.","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"It will cause an infinite loop.","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"It will update the value of name once and not run again until name is changed from the outside.","comment":{"@type":"Comment","text":"Option C is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"Which choice will not cause a React component to rerender?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is one of the component's siblings rerenders"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"if the component calls `this.setState(...)`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"the value of one of the component's props changes","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"if the component calls `this.forceUpdate()`","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":3,"encodingFormat":"text/markdown","text":"one of the component's siblings rerenders","comment":{"@type":"Comment","text":"Option D is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### You have created a new method in a class component called handleClick, but it is not working. Which code is missing?\n\n```javascript\nclass Button extends React.Component{\n\n constructor(props) {\n super(props);\n // Missing line\n }\n\n handleClick() {...}\n}\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is `this.handleClick = this.handleClick.bind(this);`"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"`this.handleClick.bind(this);`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"`props.bind(handleClick);`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"`this.handleClick.bind();`","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":3,"encodingFormat":"text/markdown","text":"`this.handleClick = this.handleClick.bind(this);`","comment":{"@type":"Comment","text":"Option D is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### React does not render two sibling elements unless they are wrapped in a fragment. Below is one way to render a fragment. What is the shorthand for this?\n\n```javascript\n\n
Our Staff
\n
Our staff is available 9-5 to answer your questions
\n\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is C"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"A","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"B","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"D","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"C","comment":{"@type":"Comment","text":"Option C is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### If you wanted to display the count state value in the component, what do you need to add to the curly braces in the `h1`?\n\n```javascript\nclass Ticker extends React.component {\n constructor(props) {\n super(props);\n this.state = { count: 0 };\n }\n render() {\n return
{}
;\n }\n}\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is this.state.count"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"count","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"state","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"state.count","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"this.state.count","comment":{"@type":"Comment","text":"Option A is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### Per the following code, when is the Hello component assigned to greeting?\n\n```javascript\nconst greeting = isLoggedIn ? : null;\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is when `isLoggedIn` is true"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"never","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"when a user logs in","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"when the Hello function is called","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"when `isLoggedIn` is true","comment":{"@type":"Comment","text":"Option B is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### In the following code block, what type is orderNumber?\n\n```javascript\nReactDOM.render(, document.getElementById('root'));\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is string"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"boolean","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"object","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"number","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"string","comment":{"@type":"Comment","text":"Option A is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### You have added a style property to the `h1` but there is an unexpected token error when it runs. How do you fix this?\n\n```javascript\nconst element =
Hi
;\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is `const element =
Hi
;`"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"`const element =
Hi
;`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"`const element =
Hi
;`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"`const element =
Hi
;`","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"`const element =
Hi
;`","comment":{"@type":"Comment","text":"Option B is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"Which function is used to update state variables in a React class component?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is `setState`"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"`replaceState`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"`refreshState`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"`updateState`","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":3,"encodingFormat":"text/markdown","text":"`setState`","comment":{"@type":"Comment","text":"Option D is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### Consider the following component. What is the default color for the star?\n\n```javascript\nconst Star = ({ selected = false }) => ;\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is grey"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"black","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"red","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"white","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"grey","comment":{"@type":"Comment","text":"Option C is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### What is the difference between the click behaviors of these two buttons(assuming that this.handleClick is not bound correctly)\n\n```javascript\n A. \n B. \n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is `Button A will not fire the handler this.handleClick successfully`"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"`Button A will not have access to the event object on click of the button`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"`There is no difference`","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"`Button B will not fire the handler this.handleClick successfully`","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"`Button A will not fire the handler this.handleClick successfully`","comment":{"@type":"Comment","text":"Option B is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"How would you add to this code, from React Router, to display a component called About?","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is A"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"B","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"C","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"D","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"A","comment":{"@type":"Comment","text":"Option A is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### Which class-based component is equivalent to this function component?\n\n```javascript\nconst Greeting = ({ name }) =>
Hello {name}!
;\n```","encodingFormat":"text/markdown","comment":{"@type":"Comment","text":"Correct answer is C"},"suggestedAnswer":[{"@type":"Answer","position":0,"encodingFormat":"text/markdown","text":"A","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":1,"encodingFormat":"text/markdown","text":"B","comment":{"@type":"Comment","text":"It is wrong option."}},{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"D","comment":{"@type":"Comment","text":"It is wrong option."}}],"acceptedAnswer":{"@type":"Answer","position":2,"encodingFormat":"text/markdown","text":"C","comment":{"@type":"Comment","text":"Option C is correct"}}},{"@type":"Question","eduQuestionType":"Multiple choice","learningResourceType":"Practice problem","name":"Recall your knowledge of React.jto solve the questions","text":"#### Give the code below, what does the second argument that is sent to the render function describe?\n\n```javascript\nReactDOM.render(\n
when you need the browser to paint before the effect runs
[Source] (https://react.dev/reference/react/useLayoutEffect)
"useLayoutEffect is a version of useEffect that fires before the browser repaints the screen."
[Explanation]The correct answer to the question "When do you use useLayoutEffect?" is:
When you need to change the layout of the screen.
useLayoutEffect is used when you need to perform DOM mutations that rely on the updated layout of the elements. It allows you to make changes to the DOM synchronously before the browser performs its painting step. This can be useful when you need to measure or manipulate the layout, such as accessing element dimensions or positions, calculating scroll offsets, or performing other operations that require up-to-date layout information.
The other option provided as answer is not accurate:
"When you need the browser to paint before the effect runs" is not correct. The purpose of useLayoutEffect is to run the effect synchronously after the DOM updates but before the browser paints, allowing you to make layout-related changes before the visual rendering occurs.
Explanation:useLayoutEffect gets executed before the useEffect hook without much concern for DOM mutation. Even though the React hook useLayoutEffect is set after the useEffect Hook, it gets triggered first!
Q20. What is the difference between the click behaviors of these two buttons (assuming that this.handleClick is bound correctly)?
A. <button onClick={this.handleClick}>Click Me</button>
B. <button onClick={event =>this.handleClick(event)}>Click Me</button>
Button A will not have access to the event object on click of the button.
Button B will not fire the handler this.handleClick successfully.
Button A will not fire the handler this.handleClick successfully.
There is no difference.
Q21. How do you destructure the properties that are sent to the Dish component?
Q51. React does not render two sibling elements unless they are wrapped in a fragment. Below is one way to render a fragment. What is the shorthand for this?
<React.Fragment>
<h1>Our Staff</h1><p>Our staff is available 9-5 to answer your questions</p></React.Fragment>
A
<...>
<h1>Our Staff</h1><p>Our staff is available 9-5 to answer your questions</p></...>
B
<//><h1>Our Staff</h1><p>Our staff is available 9-5 to answer your questions</p><///>
C
<>
<h1>Our Staff</h1><p>Our staff is available 9-5 to answer your questions</p></>
D
<Frag>
<h1>Our Staff</h1><p>Our staff is available 9-5 to answer your questions</p></Frag>
Q52. If you wanted to display the count state value in the component, what do you need to add to the curly braces in the h1?
Q76. In this component, how do you display whether the user was logged in or not?
render() {
const isLoggedIn = this.state.isLoggedIn;
return (
<div> The user is:
</div> );
}
The user is loggedIn ? logged in : not logged in.
Write a function to check the login status.
The user is {isLoggedIn = "no"}.
The user is {isLoggedIn ? "logged in." : "not logged in"}.
Q77. You are rendering a list with React when this warning appears in the console: "Warning: Each child in a list should have a unique 'key' prop." How do you fix this issue?
Add a key prop with the same value to each item in the list
Clear the console warnings
Use the UseId hook to generate a unique key for each element in the list
When iterating over the list items, add a unique property to each list item.
Q78. How would you generate the boilerplate code for a new app that you are building to collect underpants?
Explanation:
React Components are like functions that return HTML elements. Components are independent and reusable bits of code. They serve the same purpose as JavaScript functions, but work in isolation and return HTML. Components come in two types, Class components and Function components.
Q90. You want to disable a button so that it does not emit any events onClick. Which prop do you use to acomplish this?
onBlur
onPress
defaultValue
disabled
Q91. In this function, which is the best way to describe the Dish component?
Q95. How would you modify the constructor to fix this error: "ReferenceError: Must call super constructor in derived class before accessing 'this'..."?
Q98. What would be the result of running this code?
functionadd(x = 1, y = 2) {
return x + y;
}
add();
null
3
0
undefined
Explanation: function that called without parameter will use its param default value, thus x will always be default to 1 and y will always be default to 2.
Q102. This code is part of an app that collects Pokemon. The useState hook below is a piece of state holding onto the names of the Pokemon collected so far. How would you access the collected Pokemon in state?
Explanation: useState always return an array with two values, the state itself (on first value) and the set function that lets you update the state (on second value)
useState Reference
Q103. What would you pass to the onClick prop that will allow you to pass the initName prop into the greet handler?
Explanation: Apparently the question misstyped greet as hug. Putting this aside, we can still learn from this question.
In a function, the global object is the default binding for this. In a browser window the global object is [object Window].
This is a functional Component, so this from this.hug actually refers to browser window.
Since it is a functional component, we can directly refer to hug without using this.
To pass a handler to onClick, we should always pass a function rather than execute a function. So we need to use callback here.
initName is available in Greeting's function scope, so we can directly supply as an argument to hug().
Q104. What is the name of the compiler used to transform JSX into JavaScript?
Q126. You run the following code and get this error message: "invalid hook call." what is wrong with the code?
import React from'react';
const [poked, setPoked] = React.useState(false);
functionPokeButton() {
return<buttononClick={() => setPoked(true)}>{poked ? 'You have left a poke.' : 'Poke'}</button>;
}
The useState call needs to be called inside of the PokeButton component.
The react package is likely not installed correctly.
useState is not imported correctly. Import useState directly instead of importing react.
PokeButton is a pure function and therefore cannot have any local state.
Q127. A colleague comes to you for help on a react component. They say that the poke button renders correctly, however when the button is clicked, this error is shown: "setPoked is not defined". What is wrong with their code?
functionPokeButton() {
const { poked, setPoked } = useState(false);
return<buttononclick={() => setPoked(true)}>{poked ? 'You have left a poke.' : 'Poke'}</button>;
}
onClick prop should be onclick.
The click handler passed to the onClick prop is inlined. Move this handler into a variable outside of JSX.
They use object destructructing instead of array destructructing. Wrap the poked and setPoked values in an array.
poked and setPoked are not destructured in the correct order.
Q128. This component is loaded dynamically. What should you replace XXXX with to complete the code?
Q130. You want to memorize a callback function so you ensure that React does not recreate the function at each render. Which hook would you use to accomplish this?
Q131. You want to perform a network operation as the result of a change to a component's state named userInput. what would you replace XXXX with?
useEffect(callNetworkFunc, XXXX);
[userInput]
userInput
undefined
[]
Q132. When is the Hello component displayed?
<div>{isLoggedIn ? <Hello /> : null}</div>
when isLoggedIn is false
when isLoggedIn is true
when isLoggedIn is false and the Hello function is invoked
never
Q133. When do you use useLayoutEffect?
to optimize for all devices
to complete the update
to change the layout of the screen
when you need the browser to paint before the effect runs
Q134. What is the difference between state and props in React?
Props are set by the parent component, state is set by the child component
Props are passed to a component, state is managed within the component
Props can be updated, state cannot be updated
There is no difference - props and state are the same
Q135. Which language can you not use with React?
Swift.
JSX.
Javascipt.
TypeScript.
Q136. Which answer best describes a function component?
A function component is the same as a class component.
A function component accepts a single props object and returns a React element.
A function component is the only way to create a component.
A function component is required to create a React component.
Q137. Which library does the fetch() function come from?
FetchJS
ReactDOM
No library. fetch() is supported by most browsers.
React
Q138. In React, what is the purpose of the key prop when rendering a list of components
The key prop is used to provide a unique identifier for the component.
The key prop is used to define the color of the component.
The key prop is required to render a list of components.
The key prop is used by React to optimize updates and identify which items have changed or been added/removed in the list.
Q139. What is the primary function of React Router?
React Router is used for fetching data from APIs.
React Router is used to create animations in React applications.
React Router is used for managing state in React components.
React Router is used for adding navigation and routing to React applications, allowing users to navigate between different views or pages.
Q140. When should you use Redux in a React application?
Redux is always required in React applications.
Redux should be used when you need to fetch data from APIs.
Redux is used for creating user interfaces but not for state management.
Redux is typically used when you have complex state management needs, such as sharing state between multiple components or handling deeply nested state.
Q141. What is the use of React hooks?
To optimize React apps for mobile devices
To add visual effects to React components.
To allow using state and lifecycle methods in function components
To integrate with external UI libraries like Bootstrap
Q142. How can you pass data through a React component tree without having to pass props down manually at every level?