-
Notifications
You must be signed in to change notification settings - Fork 16
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
base: master
Are you sure you want to change the base?
HT-6 Kostenevich #83
Conversation
<Route | ||
path="/" | ||
exact | ||
component={() => <Redirect to={`/restaurants`} />} | ||
/> |
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.
вот так
<Route | |
path="/" | |
exact | |
component={() => <Redirect to={`/restaurants`} />} | |
/> | |
<Redirect exact from="/" to="/restaurants" /> |
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.
понял, спасибо
export const restaurantByProductIdSelector = createSelector( | ||
[restaurantsSelector, (state, ownProps) => ownProps.product.id], | ||
(restaurants, id) => { | ||
const restaurant = Object.values(restaurants).find((restaurant) => |
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.
Вот это пересчитывается для каждого элемента корзины при каждом рендере. Можно сделать немного оптимальнее, разделив на 2 селектора. Покажу на своей домашке.
{({ match }) => { | ||
console.log(match.params); | ||
|
||
switch (match.params.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.
проще сделать несколько Route, покажу на своей домашке
Сама домашка лёгкая, но есть один непонятный момент. Как лучше редиректить с '/'? в голове было куча вариантов, остановился на том что бы в Component передать '<Redirect to={
/restaurants
} />', однако можно и просто передать компонент Restaurants, ну или в Component передать '<Route...>' и тд. Хотел бы вот об этом вот узнать, спасибо заранее.