Skip to content

Add components #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add components #2

wants to merge 2 commits into from

Conversation

tensaida
Copy link
Owner

The deployed Netlify app has a bug #1

@netlify
Copy link

netlify bot commented Nov 15, 2022

Deploy Preview for exquisite-pothos-d44e7c ready!

Name Link
🔨 Latest commit ae4916e
🔍 Latest deploy log https://app.netlify.com/sites/exquisite-pothos-d44e7c/deploys/63737103e40e1b00089d65d5
😎 Deploy Preview https://deploy-preview-2--exquisite-pothos-d44e7c.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Copy link

@yanislav-igonin yanislav-igonin left a comment

Choose a reason for hiding this comment

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

Nice work, really love the design with a masonry layout!

Haven't seen pagination, also useEffect makes the CPU fly to the moon.

Overall, good job!

@@ -1,31 +1,30 @@
import { useState } from 'react'
import { useState, useEffect } from 'react'

Choose a reason for hiding this comment

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

Do not forget do delete unused code :)


useEffect(() => {
getDetail(id).then(value => setPokemon(value))
});

Choose a reason for hiding this comment

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

Do not forget to add dependency array as a second argument

useEffect(() => {
    getDetail(id).then(value => setPokemon(value))
}, [id]);

Choose a reason for hiding this comment

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

Or requests goes brrrr
2022-11-15 15 22 26

let getDetail = async function(id: string): Promise<Pokemon> {
const ability = (await getOne(id)).data.abilities[0].ability.name;
const numId = parseInt(id);
const name = (await getList(numId - 1, 1)).data.results[0].name;

Choose a reason for hiding this comment

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

No need to make second request for one pokemon from the list, one can obtain name from the getOne request too.

Choose a reason for hiding this comment

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

image


if (pokemon == undefined) {
return (
<h1>Loading...</h1>

Choose a reason for hiding this comment

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

Like that you added loading placeholder, good job


useEffect(() => {
getList(0, 9).then(values => setPosts(values.data.results))
})

Choose a reason for hiding this comment

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

Same here with dependencies array

useEffect(() => {
  getList(0, 9).then(values => setPosts(values.data.results))
}, [])

This will prevent infinite request calls.

getList(0, 9).then(values => setPosts(values.data.results))
})

console.log('hmm')

Choose a reason for hiding this comment

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

Do not forget to remove logs, so they won't be in production

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