- 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.js
Ingredients.js
PUT YOUR ANSWER HERE
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
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
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
Prompt: What, specifically, happens when this method is called?
ReactDOM.render(
<Kangaroos />,
document.getElementById('root')
)
Choices:
-
The
ReactDOM.render
method generates a virtual DOM node containing whatever content theKangaroos
component 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.render
method generates a virtual DOM node containing whatever the JSX that theKangaroos
component returns. React then reloads the entire webpage, changing only the element with an ID ofroot
. -
The
ReactDOM.render
method returns JSX to theKangaroos
component, and theKangaroos
component returns a virtual DOM node. React updates on the webpage only the elements specified inKangaroos
that have changed. -
The
ReactDOM.render
method generates a new element with an ID ofroot
, which it populates with the JSX returned from theKangaroos
component. 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
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
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
Store
component call needs to end with/>
, not just>
- The prop name and variable name need to match -
buy_me
needs to bemilk
andme_too
needs to bespices
- The
const groceryList
declaration needs to be inside therender
method - When passing the props into
Store
, the syntax isthis.groceryList.important
andthis.groceryList.spices
PUT YOUR ANSWER HERE
Prompt: How could you use create-react-app
to create a new app called jungle_maze
?
Choices:
create-react-app npm/start jungle_maze
create-react-app jungle_maze.js
create-react-app jungle_maze
create-react-app index/jungle_maze.js
PUT YOUR ANSWER HERE
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
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