Skip to content

Commit

Permalink
refactor: LongReviewItem 컴포넌트가 외부의 event를 props로 받을 수 있도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
chysis committed Aug 8, 2024
1 parent 795289f commit 56067d8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions frontend/src/components/common/LongReviewItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,35 @@ interface LongReviewItemProps extends TextareaHTMLAttributes<HTMLTextAreaElement
minLength: number;
maxLength: number;
initialValue?: string;
handleTextareaChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
}

const LongReviewItem = ({ minLength, maxLength, initialValue = '', style, ...rest }: LongReviewItemProps) => {
const LongReviewItem = ({
minLength,
maxLength,
initialValue = '',
handleTextareaChange,
style,
...rest
}: LongReviewItemProps) => {
const { value, textLength, isError, errorMessage, handleChange, handleBlur } = useLongReviewItem({
minLength,
maxLength,
initialValue,
});

const handleWriteTextarea = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
handleChange(e);
handleTextareaChange(e);
};

return (
<S.TextareaContainer>
<S.Textarea
value={value}
$isError={isError}
$style={style}
onChange={handleChange}
onChange={handleWriteTextarea}
onBlur={handleBlur}
{...rest}
/>
Expand Down

0 comments on commit 56067d8

Please sign in to comment.