Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
firstReact
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
찬주 이
firstReact
Commits
c498a081
Commit
c498a081
authored
2 years ago
by
찬주 이
Browse files
Options
Downloads
Patches
Plain Diff
end
parent
07cb923f
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#7560
passed
2 years ago
Stage: deploy
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
public/app.bundle.js
+1
-1
1 addition, 1 deletion
public/app.bundle.js
src/App.js
+46
-22
46 additions, 22 deletions
src/App.js
with
47 additions
and
23 deletions
public/app.bundle.js
+
1
−
1
View file @
c498a081
Source diff could not be displayed: it is too large. Options to address this:
view the blob
.
This diff is collapsed.
Click to expand it.
src/App.js
+
46
−
22
View file @
c498a081
import
React
,
{
useState
,
useEffect
,
useMemo
}
from
'
react
'
;
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
const
TimeButton
=
(
props
)
=>
{
const
TimeButton
=
(
props
)
=>
{
const
[
time
,
setTime
]
=
useState
(
null
);
const
[
time
,
setTime
]
=
useState
(
null
);
const
timer
=
useMemo
(()
=>
{
const
[
show
,
setShow
]
=
useState
(
false
);
return
setInterval
(()
=>
{
let
timer
=
null
;
let
date
=
new
Date
();
let
options
=
{
timeZone
:
props
.
tz
,
weekday
:
'
long
'
,
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
hour
:
'
numeric
'
,
minute
:
'
numeric
'
,
second
:
'
numeric
'
};
const
startTimer
=
()
=>
{
let
formattedDate
=
date
.
toLocaleDateString
(
undefined
,
options
);
timer
=
setInterval
(()
=>
{
setTime
(
formattedDate
);
displayTime
(
);
},
1000
);
},
1000
);
}
,
[
props
.
tz
])
;
};
useEffect
(()
=>
{
const
stopTimer
=
()
=>
{
return
()
=>
{
clearInterval
(
timer
);
clearInterval
(
timer
);
timer
=
null
;
};
const
handleClick
=
()
=>
{
if
(
timer
)
{
stopTimer
();
}
else
{
startTimer
();
displayTime
();
}
setShow
(
!
show
);
};
};
},
[
timer
]);
const
displayTime
=
()
=>
{
const
displayTime
=
()
=>
{
let
date
=
new
Date
();
let
date
=
new
Date
();
let
options
=
{
timeZone
:
props
.
tz
,
weekday
:
'
long
'
,
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
hour
:
'
numeric
'
,
minute
:
'
numeric
'
,
second
:
'
numeric
'
};
let
options
=
{
timeZone
:
props
.
tz
,
weekday
:
'
long
'
,
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
hour
:
'
numeric
'
,
minute
:
'
numeric
'
,
second
:
'
numeric
'
,
};
let
formattedDate
=
date
.
toLocaleDateString
(
undefined
,
options
);
let
formattedDate
=
date
.
toLocaleDateString
(
undefined
,
options
);
setTime
(
formattedDate
);
setTime
(
formattedDate
);
}
};
useEffect
(()
=>
{
return
()
=>
{
stopTimer
();
};
},
[]);
return
(
return
(
<>
<>
<
button
onClick
=
{
displayTime
}
tz
=
{
props
.
tz
}
>
{
props
.
name
}
<
/button
>
<
button
onClick
=
{
handleClick
}
>
{
props
.
name
}
<
/button
>
<
div
id
=
'
time
'
>
{
time
}
<
/div
>
{
show
&&
<
div
id
=
'
time
'
>
{
time
}
<
/div>
}
<
/
>
<
/
>
);
);
}
}
;
const
App
=
()
=>
{
const
App
=
()
=>
{
const
cityListConst
=
[
const
cityListConst
=
[
{
cityName
:
"
Vienna
"
,
timezone
:
"
Europe/Vienna
"
},
{
cityName
:
'
Vienna
'
,
timezone
:
'
Europe/Vienna
'
},
{
cityName
:
"
Lord_Howe
"
,
timezone
:
"
Australia/Lord_Howe
"
},
{
cityName
:
'
Lord_Howe
'
,
timezone
:
'
Australia/Lord_Howe
'
},
{
cityName
:
"
Shanghai
"
,
timezone
:
"
Asia/Shanghai
"
}
{
cityName
:
'
Shanghai
'
,
timezone
:
'
Asia/Shanghai
'
}
,
];
];
const
[
cityList
,
setCityList
]
=
useState
(
cityListConst
);
const
[
cityList
,
setCityList
]
=
useState
(
cityListConst
);
...
@@ -51,6 +75,6 @@ const App = () => {
...
@@ -51,6 +75,6 @@ const App = () => {
<
/div
>
<
/div
>
<
/
>
<
/
>
);
);
}
}
;
export
default
App
;
export
default
App
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment