HW2#31
Conversation
|
|
||
| const formsElements = [form.email, form.password] | ||
|
|
||
| return <Auth |
There was a problem hiding this comment.
При отрисовке формы пароль не скрывается за звездочками (*), что немного неприятно)
| import {useAuthSession} from "../context/AuthContext"; | ||
| import {useHistory} from "react-router-dom"; | ||
|
|
||
| const inputLabels = ["Логин", "Пароль"] |
There was a problem hiding this comment.
Эти массивы передаются отдельно в компонент auth, и внутри этого компонента приходится обходя один из этих массивов доставать по индексу что-то из других. И никакая проверка типов в данном случае не поможет, если какие-то из элементов будут перепутаны местами.
Как вариант, если эти массивы по сути описывают поля формы, можно собрать массив с объектами, где каждый объект будет отвечать за одно поле, и эти объекты можно будет расширять доп полями (например типо для пароля):
const inputs = [
{
label: "Password",
name: "password",
type: "password"
}
]
| export const Auth = ({inputLabels, inputNames, buttonLabels, | ||
| label, formsElements, marginTop, | ||
| inputOnChange, buttonTriggers}: AuthData) => { | ||
| const StyledHeaderLabel = styled(StyledHeaderLabelCommon)` |
There was a problem hiding this comment.
StyledHeaderLabel можно тоже вынести из компонента, и доставать marginTop из пропсов, что-то вида (но лучше в доке проверить):
const StyledHeaderLabel = styled(StyledHeaderLabelCommon)`
margin-top: ${props => marginTop};
`
...
<StyledHeaderLabel marginTop={marginTop}>{label}</StyledHeaderLabel>
|
|
||
| const onChangeSession = (tokens: Maybe<Tokens>) => { | ||
| setSessionToLocalStorage(tokens) | ||
| setSession(session) |
There was a problem hiding this comment.
Здесь ошибка, в setSession передается session, который уже и так в стейте
No description provided.