- Fork and Clone this repo.
- Put your answers in this file.
- You may use any resource except each other.
- Submit a pull request when you're done.
Prompt: You have a main component, Milkshake.js, which imports and will render UI from a component Ingredients.js. Which file does the below code go in?
ReactDOM.render(
<Ingredients />,
document.getElementById('root')
);Choices:
Milkshake.jsIngredients.js
PUT YOUR ANSWER HERE
Ingredients.js
Prompt: A component is being passed a prop named flavor. What JSX would the component return in its render method to display the prop in a paragraph?
Choices:
<p>My favorite ice cream is {this.props.flavor}!</p><p>My favorite ice cream is {props.this.flavor}!</p><p>My favorite ice cream is {props.flavor}!</p><p>My favorite ice cream is {this.flavor}!</p>
PUT YOUR ANSWER HERE
My favorite ice cream is {this.props.flavor}!
Prompt: Is this a valid Component declaration?
class Paintings extends Component {
render () {
return (
<h1>Hello World!</h1>
<h3>It is time for tea.</h3>
);
}
}Choices:
- Yes
- No
PUT YOUR ANSWER HERE
Yes
Prompt: Is this a valid way to, in a file called Spices.js, render the JSX that the Cinnamon component returns to the screen?
ReactDOM.render(
<Cinnamon>,
document.getElementById('root')
);Choices:
- Yes
- No
PUT YOUR ANSWER HERE
No
Prompt: What, specifically, happens when this method is called?
ReactDOM.render(
<Kangaroos />,
document.getElementById('root')
)Choices:
-
The
ReactDOM.rendermethod generates a virtual DOM node containing whatever content theKangarooscomponent returns, and appends that to the element with an ID ofroot. Then, React compares the virtual DOM to the regular DOM and updates on the webpage only the elements that have changed. -
The
ReactDOM.rendermethod generates a virtual DOM node containing whatever the JSX that theKangarooscomponent returns. React then reloads the entire webpage, changing only the element with an ID ofroot. -
The
ReactDOM.rendermethod returns JSX to theKangarooscomponent, and theKangarooscomponent returns a virtual DOM node. React updates on the webpage only the elements specified inKangaroosthat have changed. -
The
ReactDOM.rendermethod generates a new element with an ID ofroot, which it populates with the JSX returned from theKangarooscomponent. React updates the virtual DOM to have this new element, which the browser sees to dynamically change the page with the new element on it.
PUT YOUR ANSWER HERE
The ReactDOM.render method generates a virtual DOM node containing whatever the JSX that the Kangaroos component returns. React then reloads the entire webpage, changing only the element with an ID of root
Prompt: If you have multiple components written in a single file, you can then have multiple default export statements at the bottom of that file - one for each component.
Choices:
- True
- False
PUT YOUR ANSWER HERE
Prompt: What is React.js?
Choices:
- A framework created by developers at Facebook. It is aimed at being the 'view' of your Javascript application. It focuses on creating a component-based architecture.
- A boilerplate that eliminates displaying JSON retrieved from your server. It updates the model portion of your web application to dynamically render UI.
- A library of independent, reusable pieces of user interface that you can call upon to add variability to your application.
- All of the above
PUT YOUR ANSWER HERE
All of the above
Prompt: Take a look at the following React file. Choose the reason(s) it won't run properly.
import React from 'react';
import ReactDOM from 'react-dom';
import Store from './Store.js';
const groceryList = {
important: "milk",
spices: [
"pepper",
"salt"
]
}
ReactDOM.render(
<Store
buy_me={groceryList.milk}
me_too={groceryList.spices}
>,
document.getElementById('root')
);Choices:
- The
Storecomponent call needs to end with/>, not just> - The prop name and variable name need to match -
buy_meneeds to bemilkandme_tooneeds to bespices - The
const groceryListdeclaration needs to be inside therendermethod - When passing the props into
Store, the syntax isthis.groceryList.importantandthis.groceryList.spices
PUT YOUR ANSWER HERE
The Store component call needs to end with />, not just >
Prompt: How could you use create-react-app to create a new app called jungle_maze?
Choices:
create-react-app npm/start jungle_mazecreate-react-app jungle_maze.jscreate-react-app jungle_mazecreate-react-app index/jungle_maze.js
PUT YOUR ANSWER HERE
reate-react-app jungle_maze
Prompt: If I'm displaying multiple nested components, assuming the Flowers component is being passed all necessary props and the Daisy component is imported and written correctly, is this valid syntax?
import React, { Component } from 'react';
import Daisy from './Daisy.js';
class Flowers extends Component {
render() {
let allDaisies = [
<Daisy body={this.props.spring} />,
<Daisy body={this.props.rabbits} />
]
return (
<div>
<h1>{this.props.favorites}</h1>
<h3>Daisies:</h3>
{allDaisies}
</div>
);
}
}Choices:
- Yes
- No
PUT YOUR ANSWER HERE
Yes
Prompt: Where does constructor() go, and when do you need it?
Choices:
-
At the top of the component class; you always need it for accurate setup of that class.
-
At the top of the component class; you only need it if you are changing any initial configurations for that class.
-
In the component class'
render()method; you always need it for accurate setup of that class. -
In the component class'
render()method; you only need it if you are changing any initial configurations for that class.
PUT YOUR ANSWER HERE
At the top of the component class; you only need it if you are changing any initial configurations for that class.
