10. What is the name of the tool used to take JSX and turn it into createElement calls?
JSX Editor
ReactDOM
Browser Buddy
Babel
11. Why might you use useReducer over useState in a React component?
when you want to replace Redux
when you need to manage more complex state in an app
when you want to improve performance
when you want to break your production app
12. Which props from the props object is available to the component with the following syntax?
<Message {...props} />
any that have not changed
all of them
child props
any that have changed
13. Consider the following code from React Router. What do you call :id in the path prop?
<Route path="/:id" />
This is a route modal
This is a route parameter
This is a route splitter
This is a route link
14. If you created a component called Dish and rendered it to the DOM, what type of element would be rendered?
function Dish() {
return <h1>Mac and Cheese</h1>;
}
ReactDOM.render(<Dish />, document.getElementById('root'));
div
section
component
h1
15. What does this React element look like given the following function? (Alternative: Given the following code, what does this React element look like?)
Q48. 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.
Q49. Which library does the fetch() function come from?
FetchJS
ReactDOM
No library. fetch() is supported by most browsers.
React
Q50. What will happen when this useEffect Hook is executed, assuming name is not already equal to John?
useEffect(() => {
setName('John');
}, [name]);
It will cause an error immediately.
It will execute the code inside the function, but only after waiting to ensure that no other component is accessing the name variable.
It will update the value of name once and not run again until name is changed from the outside.
It will cause an infinite loop.
Q51. Which choice will not cause a React component to rerender?
if the component calls this.setState(...)
the value of one of the component’s props changes
if the component calls this.forceUpdate()
one of the component’s siblings rerenders
Q52. You have created a new method in a class component called handleClick, but it is not working. Which code is missing?
class Button extends React.Component{
constructor(props) {
super(props);
// Missing line
}
handleClick() {...}
}
this.handleClick.bind(this);
props.bind(handleClick);
this.handleClick.bind();
this.handleClick = this.handleClick.bind(this);
Q53. 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>
Q54. 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?