Skip to content

ДЗ6. Переписать проект на React#4

Open
dCatherinee wants to merge 3 commits into
mainfrom
homework6
Open

ДЗ6. Переписать проект на React#4
dCatherinee wants to merge 3 commits into
mainfrom
homework6

Conversation

@dCatherinee

Copy link
Copy Markdown
Owner

No description provided.

Comment thread src/components/Catalog/Catalog.js Outdated
const [products, setProsucts] = useState();

useEffect(() => {
axios.get('http://localhost:3006/item').then(resp => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

давай немного настроим axios, сделаем отделный объект в котором уже будет зашит общий url

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

создадим папку src/api и там index.js (по идее более правильно будет резделить в папке на отделный файлы, но не будем усложнять) и там уже отдельно сделаем методы получения данных

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

т. е. здесь будет вызываться метод getItems()

Comment thread src/components/Catalog/Catalog.js Outdated
};

return (
<>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

фрагмент здесь не нужен

}

return (
<>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

фрагмент не нужен

const [info, setInfo] = useState();

useEffect(() => {
axios.get('http://localhost:3006/item/:itemId').then(resp => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

сюда по идее id надо подставлять

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

вместо :itemId, т. е. с условием того что методы получения данных вынесем в отдельные папки, здесь будет что-то типа
getItem(id)

const product = props.product;

return (
<>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

фрагмент здесь лишний

Comment thread src/App.js Outdated
<Header />
<Routes>
<Route path='/' exact element={<Catalog />} />
<Route path='/info-product' exact element={<ProductInfo />} />

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

давай сделаем здесь
path='/info-product/:id'
чтоб как по правде было, а в компоненте карточки в каталоге будем переходит по роуту с соответствующим id

Comment thread src/components/Catalog/Catalog.js Outdated

if (!products || products.lenght === 0) {
return (
<>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

фрагмент здесь не нужен

};

return (
<>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

фрагмент здесь не нужен

Comment thread src/components/Header/Header.js Outdated
};

return (
<>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

фрагмент здесь не нужен


return (
<>
<CardWrapper to='/info-product'>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

давай здесь сделаем переход с указанием id

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