Skip to content

Commit 4c64ae0

Browse files
brz95kuduzow
andauthored
Исправил ошибку которую выдавала консоль (#332)
* Исправил ошибку которую выдавала консоль * Исправил ошибку еще в одном месте * Добавил компонент CancelLinkLabel для сохранения атрибутов Typography.Text и переместил Typography.Link в пропс component * fix: wrap CancelLinkLabel with right props --------- Co-authored-by: Kuduzow Akhmad <ammya@ya.ru>
1 parent 93054a2 commit 4c64ae0

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

src/features/questions/create-question/CreateQuestionPage.jsx

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useCallback, useEffect, useRef } from 'react';
1+
import React, { useState, useCallback, useEffect, useRef } from 'react';
22
import { useDispatch, useSelector } from 'react-redux';
33
import { Link, Redirect } from 'react-router-dom';
44
import styled from 'styled-components';
@@ -11,6 +11,7 @@ import { addQuestion } from 'features/questions/questionsSlice';
1111
import { selectProfile } from 'features/profile/profileSlice';
1212
import { useAuth } from 'common/context/Auth/useAuth';
1313
import { MAX_NUMBER_OF_TAGS, TAG_MAX_LENGTH } from 'app/constants';
14+
import PropTypes from 'prop-types';
1415

1516
const StyledQuestionWrapper = styled.div`
1617
& .new-tag {
@@ -70,6 +71,26 @@ const StyledTagBlock = styled.div`
7071
margin-top: 5px;
7172
`;
7273

74+
const CancelButtonWrapper = styled.span`
75+
cursor: pointer;
76+
`;
77+
78+
const CancelLinkLabel = ({ navigate, href, children }) => {
79+
return (
80+
<CancelButtonWrapper>
81+
<Typography.Text type="secondary" onClick={() => navigate(href)}>
82+
{children}
83+
</Typography.Text>
84+
</CancelButtonWrapper>
85+
);
86+
};
87+
88+
CancelLinkLabel.propTypes = {
89+
navigate: PropTypes.func.isRequired,
90+
href: PropTypes.string.isRequired,
91+
children: PropTypes.node.isRequired,
92+
};
93+
7394
const CreateQuestion = () => {
7495
const dispatch = useDispatch();
7596
const editorRef = useRef();
@@ -156,8 +177,8 @@ const CreateQuestion = () => {
156177
<div className="container m-3 m-md-auto">
157178
<div className="d-flex justify-content-between my-3">
158179
<h3>Добавление вопроса</h3>
159-
<Link to="/">
160-
<Typography.Link>Вернуться назад</Typography.Link>
180+
<Link to="/" component={Typography.Link}>
181+
Вернуться назад
161182
</Link>
162183
</div>
163184
</div>
@@ -260,8 +281,8 @@ const CreateQuestion = () => {
260281
</Button>
261282
</div>
262283
<div className="col-auto">
263-
<Link to="/" className="cancel">
264-
<Typography.Text type="secondary">Отмена</Typography.Text>
284+
<Link to="/" component={CancelLinkLabel}>
285+
Отмена
265286
</Link>
266287
</div>
267288
</div>

0 commit comments

Comments
 (0)