emotion diary : fix error

This commit is contained in:
haerong22
2022-04-23 03:13:49 +09:00
parent 833117d08e
commit 5958339a81
7 changed files with 28 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@@ -1,15 +1,13 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="ko">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" /> <meta name="theme-color" content="#000000" />
<meta <meta name="description" content="나만의 감정 일기장" />
name="description"
content="Web site created using create-react-app"
/>
<title>React App</title> <title>감정 일기장</title>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>

View File

@@ -49,9 +49,11 @@ function App() {
const diaryList = JSON.parse(localData).sort( const diaryList = JSON.parse(localData).sort(
(a, b) => parseInt(b.id) - parseInt(a.id) (a, b) => parseInt(b.id) - parseInt(a.id)
); );
dataId.current = parseInt(diaryList[0].id) + 1;
dispatch({ type: "INIT", data: diaryList }); if (diaryList.length >= 1) {
dataId.current = parseInt(diaryList[0].id) + 1;
dispatch({ type: "INIT", data: diaryList });
}
} }
}, []); }, []);

View File

@@ -13,6 +13,11 @@ const Diary = () => {
const [data, setData] = useState(); const [data, setData] = useState();
useEffect(() => {
const titleElement = document.getElementsByTagName("title")[0];
titleElement.innerHTML = `감정 일기장 - ${id}번 일기`;
}, []);
useEffect(() => { useEffect(() => {
if (diaryList.length >= 1) { if (diaryList.length >= 1) {
const targetDiary = diaryList.find( const targetDiary = diaryList.find(

View File

@@ -11,6 +11,11 @@ const Edit = () => {
const { id } = useParams(); const { id } = useParams();
useEffect(() => {
const titleElement = document.getElementsByTagName("title")[0];
titleElement.innerHTML = `감정 일기장 - ${id}번 일기 수정`;
}, []);
useEffect(() => { useEffect(() => {
if (diaryList.length >= 1) { if (diaryList.length >= 1) {
const targetDiary = diaryList.find( const targetDiary = diaryList.find(

View File

@@ -12,6 +12,11 @@ const Home = () => {
const headText = `${curDate.getFullYear()}${curDate.getMonth() + 1}`; const headText = `${curDate.getFullYear()}${curDate.getMonth() + 1}`;
useEffect(() => {
const titleElement = document.getElementsByTagName("title")[0];
titleElement.innerHTML = `감정 일기장`;
}, []);
useEffect(() => { useEffect(() => {
if (diaryList.length >= 1) { if (diaryList.length >= 1) {
const firstDay = new Date( const firstDay = new Date(

View File

@@ -1,6 +1,11 @@
import { useEffect } from "react";
import DiaryEditor from "../components/DiaryEditor"; import DiaryEditor from "../components/DiaryEditor";
const New = () => { const New = () => {
useEffect(() => {
const titleElement = document.getElementsByTagName("title")[0];
titleElement.innerHTML = `감정 일기장 - 새 일기`;
}, []);
return ( return (
<div> <div>
<DiaryEditor /> <DiaryEditor />