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

HT-6 Kostenevich #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

HT-6 Kostenevich #83

wants to merge 1 commit into from

Conversation

klmncr
Copy link

@klmncr klmncr commented Nov 1, 2021

Сама домашка лёгкая, но есть один непонятный момент. Как лучше редиректить с '/'? в голове было куча вариантов, остановился на том что бы в Component передать '<Redirect to={/restaurants} />', однако можно и просто передать компонент Restaurants, ну или в Component передать '<Route...>' и тд. Хотел бы вот об этом вот узнать, спасибо заранее.

Comment on lines +13 to +17
<Route
path="/"
exact
component={() => <Redirect to={`/restaurants`} />}
/>
Copy link
Owner

Choose a reason for hiding this comment

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

вот так

Suggested change
<Route
path="/"
exact
component={() => <Redirect to={`/restaurants`} />}
/>
<Redirect exact from="/" to="/restaurants" />

Copy link
Author

Choose a reason for hiding this comment

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

понял, спасибо

export const restaurantByProductIdSelector = createSelector(
[restaurantsSelector, (state, ownProps) => ownProps.product.id],
(restaurants, id) => {
const restaurant = Object.values(restaurants).find((restaurant) =>
Copy link
Owner

Choose a reason for hiding this comment

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

Вот это пересчитывается для каждого элемента корзины при каждом рендере. Можно сделать немного оптимальнее, разделив на 2 селектора. Покажу на своей домашке.

{({ match }) => {
console.log(match.params);

switch (match.params.id) {
Copy link
Owner

Choose a reason for hiding this comment

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

проще сделать несколько Route, покажу на своей домашке

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