-
Notifications
You must be signed in to change notification settings - Fork 99
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
Nick/lesson21 #45
Nick/lesson21 #45
Conversation
src/components/ErrorBoundary.tsx
Outdated
constructor(props: Props) { | ||
super(props); | ||
this.state = { hasError: false }; | ||
} |
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.
comon, class-properties уже давно подключен )
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.
Я копировал код с документации )
Фикс будет
src/components/Field/Cell.tsx
Outdated
|
||
import { CellItem } from "./CellItems"; | ||
|
||
export interface Props { |
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.
я все же голосую за CellProps
import { actions } from "./reducer"; | ||
|
||
const mapStateToProps = ({ game }: TicTacToeGameState) => ({ | ||
field: game.gameField, |
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.
а еще я за использование селекторов, хотя в маленьком приложении это оверкилл, наверное
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.
Попробую подумать над примером )
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 mapStateToProps = (state: TicTacToeGameState) => ({
field: selectGameField(state),
});
click: actions.click, | ||
}; | ||
|
||
export type Props = ReturnType<typeof mapStateToProps> & |
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.
может нам под это вспомогательный дженерик замутить?
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 type Props<S, D> = S & D;
Где я торможу?)
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 { GameState } from "./GameState"; | ||
export { InteractiveField } from "./InteractiveField"; | ||
|
||
export { gameSlice } from "./reducer"; |
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.
может наружу выставим {reducer, actions}
а не слайс? (они уже экспортируются так)
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.
Тогда будет много конфликтов имён
в reducer.ts можно найти строчку export const { reducer, actions } = gameSlice;
, если есть желание делать раздельный импорт, тогда можно сделать это из файла reducer.ts
No description provided.