-
Notifications
You must be signed in to change notification settings - Fork 0
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
Hw 4 #4
base: main
Are you sure you want to change the base?
Conversation
import RepoSearchPage from "./components/RepoSearchPage"; | ||
import { BrowserRouter, Route, Redirect} from "react-router-dom"; | ||
import { RepoItem } from "../../../store/GitHubStore/types"; | ||
import RepoBranchesDrawer from "@components/RepoBranchesDrawer"; | ||
// import { RepoItem } from "../../../store/ReposListStore/types"; |
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.
весь неиспользуемый код должен быть удален
import { RepoItemModel } from "@models/gitHub"; | ||
import {Meta} from "@utils/meta"; | ||
import ErrorImage from "@components/ErrorImage"; | ||
import LoadingSpin from "@components/LoadingSpin"; | ||
|
||
|
||
const RepoSearchPage = () => { | ||
const [value, setValue] = useState<string>(""); |
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.
Значение инпута должно храниться в сторе
|
||
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
const handleChange = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => { |
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.
на самом деле на практике сильно удобнее, если доработать инпут так, чтобы он в onChange уже сразу передавал e.target.value, тогда тут бы приходила просто строка
} else { | ||
//alert("nothing"); | ||
const handleClick = React.useCallback(() => { | ||
const getresult = async () => { |
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.
зачем сначала создается функция, а потом вызывается? В теле функции можно было бы выполнить эту логику сразу
const handleClick = React.useCallback(() => { | ||
const getresult = async () => { | ||
try { | ||
await gitHubStore.GetOrganizationReposListParams({ |
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.
функция внутри и так оборачивает в try catch обработку данных. Незачем здесь писать дополнительный try catch
|
||
} | ||
<Route path="/repos/:id" component={RepoBranchesDrawerShower} /> |
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.
Нужно все роуты вынести пути в конфиг-файл типа такого
routes = {
reposDetails: {
mask: "/repos/:id",
create: (id: string): string => `/repos/${id}`
}
}
const ErrorImage = () => { | ||
|
||
return ( | ||
<> |
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.
- Зачем здесь фрагмент?)
- На проекте явно не применен линтер
- Стоит ли этот комопонент обернуть в React.memo? Да. Нужно првоерить весь код
|
||
}; | ||
|
||
export default (LoadingSpin); |
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.
А зачем скобочки?
|
||
type PrivateFields = "_params"; | ||
|
||
export default class QueryParamsStore { |
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.
стор используется?
method: HTTPMethod.GET, | ||
data: {}, | ||
headers: {}, | ||
endpoint: `orgs/${params.organizationName}/repos` |
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.