Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design1
/
Triz_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
sdy
2020-05-16 14:59:47 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5ecffc7b1799b92cc592f54d42a12920e1f2c919
5ecffc7b
1 parent
2cdd69bd
update Timer in HomeDate.js
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
4 deletions
front/src/Components/Home/HomeDate.js
front/src/Components/Home/HomeDate.js
View file @
5ecffc7
import
React
from
"react"
;
import
React
,
{
useState
,
useEffect
}
from
"react"
;
import
styled
from
"styled-components"
;
import
moment
from
"moment"
;
const
HomeDate
=
styled
.
div
`
display: flex;
...
...
@@ -10,18 +11,37 @@ const WeatherBox = styled.div``;
const
WeatherSpan
=
styled
.
span
``
;
const
DateBox
=
styled
.
div
``
;
const
DateBox
=
styled
.
div
`
display: flex;
flex-direction: column;
`
;
const
DateSpan
=
styled
.
span
``
;
const
DateSpan
=
styled
.
span
`
font-size:
${(
props
)
=>
{
if
(
props
.
className
===
"Clock"
)
return
"45px"
;
}};
`;
export default () => {
const [date, setDate] = useState(moment().format("h:mm:ss a"));
useEffect(() => {
let timer = setInterval(() => tick(), 1000);
return function cleanUp() {
clearInterval(timer);
};
});
function tick() {
setDate(moment().format("h:mm:ss a"));
}
return (
<HomeDate>
<WeatherBox>
<WeatherSpan /> Weather
</WeatherBox>
<DateBox>
<
DateSpan
/>
Date
<DateSpan
className="Clock">{date}</DateSpan>
</DateBox>
</HomeDate>
);
...
...
Please
register
or
login
to post a comment