diff --git a/simplediary/src/DiaryEditor.js b/simplediary/src/DiaryEditor.js index d39fe878..0883c8b8 100644 --- a/simplediary/src/DiaryEditor.js +++ b/simplediary/src/DiaryEditor.js @@ -1,10 +1,13 @@ -import { useState } from "react"; +import React, { useRef, useState } from "react"; const DiaryEditor = () => { + const authorInput = useRef(); + const contentInput = useRef(); + const [state, setState] = useState({ author: "", content: "", - emotion: 1, + emotion: 5, }); const handleChangeState = (e) => { @@ -15,7 +18,16 @@ const DiaryEditor = () => { }; const handleSubmit = () => { - console.log(state); + if (state.author.length < 1) { + authorInput.current.focus(); + return; + } + + if (state.content.length < 5) { + contentInput.current.focus(); + return; + } + alert("저장 성공"); }; @@ -24,6 +36,7 @@ const DiaryEditor = () => {

오늘의 일기

{