write 모듈에서 포스트 수정을 위한 코드를 작성한 후에는 WriteActionButtonsContainer와 WriteActionButtons 컴포넌트를 차례로 수정해 주세요.
containers/write/WriteActionButtonsContainer.js
import React, { useEffect } from 'react'; import WriteActionButtons from '../../components/write/WriteActionButtons'; import { useSelector, useDispatch } from 'react-redux'; import { withRouter } from 'react-router-dom'; import { writePost, updatePost } from '../../modules/write'; const WriteActionButtonsContainer = ({ history }) => { const dispatch = useDispatch(); const { title, body, tags, post, postError, originalPostId } = useSelector( ({ write }) => ({ title: write.title, body: write.body, tags: write.tags, post: write.post, postError: write.postError, originalPostId: write.originalPostId, }), ); // 포스트 등록 const onPublish = () => { if (originalPostId) { dispatch(updatePost({ title, body, tags, id: originalPostId })); return; } dispatch( writePost({ title, body, tags, }), ); }; (...) return ( <WriteActionButtons onPublish={onPublish} onCancel={onCancel} isEdit={!!originalPostId} /> ); }; export default withRouter(WriteActionButtonsContainer);