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

refactor: mentor's review fixes for Dictionary #6

Merged
merged 2 commits into from
Mar 23, 2021

Conversation

AlexeyTeterin
Copy link
Collaborator

No description provided.

@AlexeyTeterin AlexeyTeterin changed the title refactor: mentor's review fixes refactor: mentor's review fixes for Dictionary Mar 23, 2021
const dispatch = useDispatch();
const classes = makeStyles(() => styles)();

const fetch = () => dispatch(fetchDictionary());
Copy link
Owner

Choose a reason for hiding this comment

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

Имя fetch ни о чём не говорит, хочется больше конкретики, что именно фетчим. Но лучше, чтобы оно не совпадало с fetchDictionary - трудно понимать, где экшн, где метод

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Может, getDictionary тогда?

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
Collaborator Author

Choose a reason for hiding this comment

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

done

payload: { words },
};
}
export const fetchDictionarySuccess = (words: IWord[]) => ({
Copy link
Collaborator

Choose a reason for hiding this comment

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

IWord[] как Array вроде хотели писать?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

};
}
export const fetchDictionary = () => async (dispatch: Dispatch) => {
const apiURL = 'https://react-learnwords-example.herokuapp.com/words';
Copy link
Collaborator

Choose a reason for hiding this comment

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

в consts вынести нужно, наверное. Или все равно потом другой подставлять...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

state: IDictionary = initialState,
action: IDictionaryAction
) {
const dictionaryReducer = (state: IDictionary = initialState, action: IDictionaryAction) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

у нас isLoading в AppState переехал

export const fetchDictionary = () => async (dispatch: Dispatch) => {
dispatch(fetchDictionaryStart());
try {
const res = await fetch(`${backendUrl}/words`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be nice if fetchDictionary function will take two value. For example "page" & "group", for this link https://react-learnwords-example.herokuapp.com/words?page=2&group=0

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Будет сделано в будущем ) это пока что "скелет"

@@ -24,21 +24,19 @@ export interface IWord {
textExampleTranslate: string;
}

export interface IDictionaryState {
export interface IWordBookState {
isLoading: boolean;
words: IWord[];
Copy link
Owner

Choose a reason for hiding this comment

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

Вот в таких местах как раз ментором рекомендовано делать Array<IWord>

@lbratkovskaya lbratkovskaya merged commit 35265ff into develop Mar 23, 2021
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.

6 participants