-
Notifications
You must be signed in to change notification settings - Fork 11
Ksenia Myakinkaya #7
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
base: master
Are you sure you want to change the base?
Conversation
| import { Pockemon_card } from '../pockemon_card/Pockemon_card'; | ||
| import './app_container.scss'; | ||
|
|
||
| export function App_container(props) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
принято все же писать названия классов в CamelCase
components/header/header.jsx
Outdated
| return ( | ||
| <header> | ||
| <Link to="/"><h1 className="text">Pokedex</h1></Link> | ||
| <Link to="/caught"><span className="text">Пойманные покемоны</span></Link> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вынеси все пути в константы
containers/CatchButtonContainer.jsx
Outdated
| if (caught===null) return (<></>) | ||
| else return( | ||
| <> | ||
| {caught && <Catch_button onClick={this.handleCatchButton} disable={caught} text='Пойман' />} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
почему бы не вынести определение, какой текст должен быть у кнопки из jsx и упростить рендер до
return caught === null ? null :
<CatchButton onClick={this.handleCatchButton} disable={caught} text={buttonText} />
containers/CaughtContainer.jsx
Outdated
| console.log(error); | ||
| return ( | ||
| <> | ||
| {!loading && !error && total===0 && <Empty_component />} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я бы все же переписал данный рендер хотя бы на тернарниках - в таком виде надо ещё посидеть и подумать, сколько различных вариантов рендера у компонента :D
containers/CatchButtonContainer.jsx
Outdated
|
|
||
| componentDidMount(){ | ||
| const {id} = this.props; | ||
| fetch(`http://localhost:3000/caught_pokemons/?id=${id}`, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я бы посоветовал вынести запрос из компонента, и сделать несколько уровней абстракции - например создать apiService, в котором будет создаваться дефолтная конфигурация http запросов, и который будет предоставлять методы ( GET, PUT, POST и т.д.). И также создать pokemonsService, который уже будет предоставлять методы getCaughtPokemon(id) и который уже будет вызывать apiService.get('http://localhost:3000/caught_pokemons', queryParams)
containers/PokemonPageContainer.jsx
Outdated
| const {name, img} = this.state; | ||
| return ( | ||
| <> | ||
| {!name &&<Loading />} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в таких случаях лучше юзать тернарный оператор
containers/CaughtContainer.jsx
Outdated
| return ( | ||
| <> | ||
| {!loading && !error && total===0 && <Empty_component />} | ||
| {total>0 && <App_container onScroll={this.handleScroll} pokemons={pokemons} />} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
насколько я вижу CaughtUnmounted и MainUnmounted почти идентичны - за исключением одной строчки в рендере CaughtUnmounted - почему бы не вынести рендер этой строки в родительский компонент и не сделать один компонент PokemonsListContainer, который в двух разных случая будет просто оборачиваться в два различных hoc connect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я думала, что стоит их разделить, потому что по смыслу это разные компоненты и может понадобиться изменить функционал одного независимо от другого.
scripts/getCaptureDate.js
Outdated
| }}) | ||
| .then(response => { | ||
| if (response.ok) { | ||
| return Promise.resolve(response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
зачем promise.resolve и promise.reject? почему бы просто не написать return response и throw new Error(response.statusText)?
scripts/getCaptureDate.js
Outdated
| } | ||
| }) | ||
| .then(response => response.json()) | ||
| .then(data => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вот этот блок я бы все же не выносил из компонента - он довольно жестко связан с его внутренней логикой и так становиться не очевидно что же может изменить стейт компонента
No description provided.