Skip to content

Commit

Permalink
refactor: add useEffect for update content
Browse files Browse the repository at this point in the history
  • Loading branch information
swgvenghy committed Aug 20, 2024
1 parent fc772ba commit 5ea4787
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ui/components/admin/modal/edit-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@ const EditModal = ({ open, setOpen, questionId }: CustomModalProps) => {
if (!question) {
return null;
}

const { content: modalTitle, answer, isChecked } = question;
const [editStatus, setEditStatus] = useState(false);
const [loading, setLoading] = useState(false);
const [content, setContent] = useState(answer.content);

useEffect(() => {
if (question) {
setContent(answer.content);
}
}, [questionId, open]);

const executeWithLoading = async (action: () => Promise<void>) => {
setLoading(true);
try {
Expand Down

0 comments on commit 5ea4787

Please sign in to comment.