Skip to content

Week5 Homework Submission#2

Open
wandrew8 wants to merge 15 commits into
frontend-application-development-uw20:masterfrom
wandrew8:master
Open

Week5 Homework Submission#2
wandrew8 wants to merge 15 commits into
frontend-application-development-uw20:masterfrom
wandrew8:master

Conversation

@wandrew8
Copy link
Copy Markdown

@wandrew8 wandrew8 commented May 13, 2020

Week 5 HW Submission

Please fill out the information below in order to complete your assignment. Feel free to update this comment later if necessary.

  • Comfort rating on this assignment (1-5): 4
  • Completion rating on this assignment: complete

I used the superhero API for this assignment. You can find the deployed site at https://wandrew8.github.io/week5-assignment/#/ or run it from local with the following environment variables set in a .env file in the root menu:

REACT_APP_API_KEY=3036462383041704

Comment thread src/App.js
<Switch>
<Route exact path="/" component={Home} />
<Route path="/hero/:heroId" component={Single} />
<Route path="/favorites" component={Favorites} />
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use exact here too?

}

// Many of the image links from the api are broken. This sets a default image source when image fails to load
addDefaultSrc = (e) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!


const renderAliases = () => {
const { aliases } = this.props.hero.biography;
if (aliases) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider something like:

if (aliases.length > 1) {
  [aliases.slice(0, aliases.length - 2).join(', '), aliases.slice(aliases.length - 2, aliases.length - 1)].join(' and ')
} else {
  ...aliases
}

I know that's kinda hard to read, but basically if the list larger than 1, take the last element and join the beginning elements with commas and append the last element with and.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants