Skip to content
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

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

Hw 4 #4

wants to merge 6 commits into from

Conversation

ADdinathe
Copy link
Owner

No description provided.

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";

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>("");

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>) => {

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 () => {

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({

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} />

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 (
<>

Choose a reason for hiding this comment

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

  1. Зачем здесь фрагмент?)
  2. На проекте явно не применен линтер
  3. Стоит ли этот комопонент обернуть в React.memo? Да. Нужно првоерить весь код


};

export default (LoadingSpin);

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 {

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`

Choose a reason for hiding this comment

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

формирование всех эндпоиндов как и роутов должно быть в отдельном конфиге

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