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

Nick/lesson21 #45

Merged
merged 13 commits into from
Jun 16, 2020
Merged

Nick/lesson21 #45

merged 13 commits into from
Jun 16, 2020

Conversation

nickovchinnikov
Copy link
Owner

No description provided.

Comment on lines 12 to 15
constructor(props: Props) {
super(props);
this.state = { hasError: false };
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

comon, class-properties уже давно подключен )

Copy link
Owner Author

Choose a reason for hiding this comment

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

Я копировал код с документации )
Фикс будет


import { CellItem } from "./CellItems";

export interface Props {
Copy link
Collaborator

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,
Copy link
Collaborator

Choose a reason for hiding this comment

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

а еще я за использование селекторов, хотя в маленьком приложении это оверкилл, наверное

Copy link
Owner Author

Choose a reason for hiding this comment

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

Попробую подумать над примером )

Copy link
Collaborator

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> &
Copy link
Collaborator

Choose a reason for hiding this comment

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

может нам под это вспомогательный дженерик замутить?

Copy link
Owner Author

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;

Где я торможу?)

export { GameState } from "./GameState";
export { InteractiveField } from "./InteractiveField";

export { gameSlice } from "./reducer";
Copy link
Collaborator

Choose a reason for hiding this comment

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

может наружу выставим {reducer, actions} а не слайс? (они уже экспортируются так)

Copy link
Owner Author

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

@nickovchinnikov nickovchinnikov merged commit 79f7ac7 into master Jun 16, 2020
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.

None yet

2 participants