fix: 강사가 answer가 없는 QnA를 바로 조회할 때의 에러 해결

This commit is contained in:
정기영 2024-08-09 17:53:38 +09:00
parent 82c57c093d
commit 6c22089bbe

View File

@ -4,7 +4,7 @@ import { useAnswerEdit } from '../../../../hooks/api/useAnswerEdit';
import { useParams } from 'react-router-dom'; import { useParams } from 'react-router-dom';
import { useRef, useEffect, useState } from 'react'; import { useRef, useEffect, useState } from 'react';
import SendIcon from '/src/assets/icons/send.svg?react'; import SendIcon from '/src/assets/icons/send.svg?react';
export default function ArticleDetailAnswerInput({ onSubmit, initialAnswer, isEditing = false }) { export default function ArticleDetailAnswerInput({ onSubmit, initialAnswer = '', isEditing = false }) {
// TODO: Textarea . Input // TODO: Textarea . Input
const { answerWrite } = useAnswerWrite(); const { answerWrite } = useAnswerWrite();
const { answerEdit } = useAnswerEdit(); const { answerEdit } = useAnswerEdit();
@ -40,6 +40,8 @@ export default function ArticleDetailAnswerInput({ onSubmit, initialAnswer, isEd
onSubmit(answer); onSubmit(answer);
}; };
console.log(answer);
return ( return (
<form <form
onSubmit={handleSubmit} onSubmit={handleSubmit}
@ -53,7 +55,7 @@ export default function ArticleDetailAnswerInput({ onSubmit, initialAnswer, isEd
placeholder="답변 작성하기" placeholder="답변 작성하기"
className={styles.input} className={styles.input}
/> />
{answer.length > 950 && <div className={styles.textLength}>{answer.length} / 1000</div>} {answer && answer.length > 950 && <div className={styles.textLength}>{answer.length} / 1000</div>}
<button <button
type="submit" type="submit"