Skip to content
Snippets Groups Projects
Commit 79af6287 authored by Jeong ui yeop's avatar Jeong ui yeop
Browse files

edit1

parent 4b7c28e3
No related branches found
No related tags found
No related merge requests found
import React, { Component } from 'react'; import React, { Component } from 'react';
const App = () => { const cityList = [
{cityName: "Seoul", timezone: "Asia/Seoul"},
{cityName: "London", timezone: "Europe/London"},
{cityName: "NewYork", timezone: "America/New_York"},
];
const TimeButton = (props) => {
let [time,setTime] = useState(null);
const displayTime = () => {
let date = new Date();
setTime(date.toLocaleString("ko-KR", { timeZone: props.tz }));
};
return (
<>
<button onClick={displayTime} tz={props.tz}>{props.name}</button>
<div id='time'>{time}</div>
</>
);
}
const App = (props) => {
let city = cityList.map((value => {
console.log(value.cityName);
return <TimeButton name={value.cityName} tz={value.timezone} />;
}));
return ( return (
<>
<h1> <h1>
What time is it? What time is it?
</h1> </h1>
</>
); );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment