sdy

rename "HomeDate" to HomeTodo

1 -import React, { useState, useEffect } from "react";
2 -import styled from "styled-components";
3 -import moment from "moment";
4 -
5 -const HomeDate = styled.div`
6 - display: flex;
7 - flex-direction: column;
8 -`;
9 -
10 -const WeatherBox = styled.div``;
11 -
12 -const WeatherSpan = styled.span``;
13 -
14 -const DateBox = styled.div`
15 - display: flex;
16 - flex-direction: column;
17 -`;
18 -
19 -const DateSpan = styled.span`
20 - font-size: ${(props) => {
21 - if (props.className === "Clock") return "45px";
22 - }};
23 -`;
24 -
25 -export default () => {
26 - const [date, setDate] = useState(moment().format("h:mm:ss a"));
27 - useEffect(() => {
28 - let timer = setInterval(() => tick(), 1000);
29 - return function cleanUp() {
30 - clearInterval(timer);
31 - };
32 - });
33 -
34 - function tick() {
35 - setDate(moment().format("h:mm:ss a"));
36 - }
37 -
38 - return (
39 - <HomeDate>
40 - <WeatherBox>
41 - <WeatherSpan /> Weather
42 - </WeatherBox>
43 - <DateBox>
44 - <DateSpan className="Clock">{date}</DateSpan>
45 - </DateBox>
46 - </HomeDate>
47 - );
48 -};