Skip to content

week 5 base assignment#13

Open
sashako8 wants to merge 1 commit into
frontend-application-development-uw20:masterfrom
sashako8:master
Open

week 5 base assignment#13
sashako8 wants to merge 1 commit into
frontend-application-development-uw20:masterfrom
sashako8:master

Conversation

@sashako8
Copy link
Copy Markdown

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): 3
  • Completion rating on this assignment: complete

state = { details: {} };

componentDidMount() {
const { id } = this.props.match.params;
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, I think you could use the useParams hook here, too.

for (var i = 1; i < 21; i++) {
fetch(`https://rickandmortyapi.com/api/character/?page=${i}`)
.then(res => res.json())
.then(data => this.setState({ characters: this.state.characters.concat(data.results) }))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
.then(data => this.setState({ characters: this.state.characters.concat(data.results) }))
.then(data => this.setState({ characters: [...this.state.characters, ...data.results] }))

Is another way to do it, I think we've talked abou this.

<h1>Rick and Morty Characters</h1>
{this.state.characters.map(character => (
<div>
<img src={character.image} />
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You could destructure all these props to save writing character over and over.

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