-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
84c52ed
to
8414e35
Compare
const dispatch = useDispatch(); | ||
const classes = makeStyles(() => styles)(); | ||
|
||
const fetch = () => dispatch(fetchDictionary()); |
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.
Имя fetch ни о чём не говорит, хочется больше конкретики, что именно фетчим. Но лучше, чтобы оно не совпадало с fetchDictionary - трудно понимать, где экшн, где метод
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.
Может, getDictionary
тогда?
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.
done
8414e35
to
0201aa9
Compare
0201aa9
to
85e0651
Compare
payload: { words }, | ||
}; | ||
} | ||
export const fetchDictionarySuccess = (words: IWord[]) => ({ |
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.
IWord[] как Array вроде хотели писать?
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.
fixed
}; | ||
} | ||
export const fetchDictionary = () => async (dispatch: Dispatch) => { | ||
const apiURL = 'https://react-learnwords-example.herokuapp.com/words'; |
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.
в consts вынести нужно, наверное. Или все равно потом другой подставлять...
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.
fixed
state: IDictionary = initialState, | ||
action: IDictionaryAction | ||
) { | ||
const dictionaryReducer = (state: IDictionary = initialState, action: IDictionaryAction) => { |
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.
у нас isLoading в AppState переехал
export const fetchDictionary = () => async (dispatch: Dispatch) => { | ||
dispatch(fetchDictionaryStart()); | ||
try { | ||
const res = await fetch(`${backendUrl}/words`); |
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.
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
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.
Будет сделано в будущем ) это пока что "скелет"
@@ -24,21 +24,19 @@ export interface IWord { | |||
textExampleTranslate: string; | |||
} | |||
|
|||
export interface IDictionaryState { | |||
export interface IWordBookState { | |||
isLoading: boolean; | |||
words: IWord[]; |
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.
Вот в таких местах как раз ментором рекомендовано делать Array<IWord>
No description provided.