inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

[리뉴얼] React로 NodeBird SNS 만들기

코멘트 작성 부분에서 스타일 추가시 짹짹 버튼이 작동이 안되는 문제..

해결된 질문

119

castinglife

작성한 질문수 74

0

import { Button, Form, Input } from 'antd';
import React, { useCallback, useState } from 'react';
import PropTypes from 'prop-types';

const CommentForm = ({ post }) => {
const [commentText, setCommentText] = useState('');

const onSubmitComment = useCallback(() => {
console.log(commentText);
}, [commentText]);

const onChangeCommentText = useCallback((e) => {
setCommentText(e.target.value);
}, []);

return (
<Form onFinish={onSubmitComment}>
<Form.Item style={{ position: 'relative', margin: 0 }}>
<Input.TextArea rows={4} value={commentText} onChange={onChangeCommentText} />
<Button style={{ position: 'absolute', right: 0, bottom: -40 }} type="primary" htmlType="submit">삐약</Button>
</Form.Item>
</Form>
);
};

CommentForm.propTypes = {
post: PropTypes.object.isRequired,
};

export default CommentForm;

<Button style={{ position: 'absolute', right: 0, bottom: -40 }} type="primary" htmlType="submit">삐약</Button>

style={{ position: 'absolute', right: 0, bottom: -40 }}

CommentForm.js   ->   Button 태그 안에 마지막에 추가하신 스타일 부분이 들어가면 짹짹 버튼이 동작을 안하는 것을 확인했는데.

이 부분이 왜 그런것인지 문의 드립니다.

p.s :  styled-component 로 적용을 해보아도 동일하게 버튼이 먹통이 됩니다..

Next.js react redux express nodejs

답변 1

0

castinglife

import styled from 'styled-components';
const ButtonWrapper = styled(Button)`
position: absolute;
right: 0px;
bottom: -40px;
z-index: 1;
`;
return (
<Form onFinish={onSubmitComment}>
<Form.Item style={{ position: 'relative', margin: 0 }}>
<Input.TextArea value={commentText} onChange={onChangeCommentText} rows={4} />
<ButtonWrapper type="primary" htmlType="submit">삐약</ButtonWrapper >
</Form.Item>
</Form>
);

또는

return (
<Form onFinish={onSubmitComment}>
<Form.Item style={{ position: 'relative', margin: 0 }}>
<Input.TextArea value={commentText} onChange={onChangeCommentText} rows={4} />
<Button style={{ position: 'absolute', right: 0, bottom: -40, zIndex: 1 }} type="primary" htmlType="submit">삐약</Button> {/* style={{ position: 'absolute', right: 0, bottom: -40 }} */}
</Form.Item>
</Form>
);

z-index: 1;

값을 주니 정상 작동하네요..^^

넥스트 버젼 질문

0

77

2

로그인시 401 Unauthorized 오류가 뜹니다

0

89

1

무한 스크롤 중 스크롤 튐 현상

0

175

1

특정 페이지 접근을 막고 싶을 때

0

103

2

createGlobalStyle의 위치와 영향범위

0

96

2

인라인 스타일 리렌더링 관련

0

91

2

vsc 에서 npm init 설치시 오류

0

146

2

nextjs 15버전 사용 가능할까요?

0

158

1

화면 새로고침 문의

0

121

1

RTK에서 draft, state 차이가 있나요?

0

153

2

Next 14 사용해도 될까요?

0

452

1

next, node 버전 / 폴더 구조 질문 드립니다.

0

349

1

url 오류 질문있습니다

0

211

1

ssh xxxxx로 우분투에 들어가려니까 port 22: Connection timed out

0

372

1

sudo certbot --nginx 에러

0

1274

2

Minified React error 콘솔에러 (hydrate)

0

470

1

카카오 공유했을 때 이전에 작성했던 글이 나오는 버그

0

247

1

프론트서버 배포 후 EADDRINUSE에러 발생

0

327

1

npm run build 에러

0

518

1

front 서버 npm run build 중에 발생한 에러들

0

381

1

서버 실행하고 브라우저로 들어갔을때 404에러

0

338

2

css 서버사이드 랜더링이 적용되지 않아서 문의 드립니다.

0

287

1

팔로워 3명씩 불러오고 데이터 합쳐주는걸로 바꾸고 서버요청을 무한으로하고있습니다.

0

238

2

해시태그 검색에서 throttle에 관해 질문있습니다.

0

201

1