Skip to content

Commit d36fb42

Browse files
committed
add usestate-hook-practice starting files
1 parent 2b2bd2f commit d36fb42

File tree

5 files changed

+103
-0
lines changed

5 files changed

+103
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "usestate-hook-practice",
3+
"version": "1.0.0",
4+
"description": "",
5+
"keywords": [],
6+
"main": "src/index.js",
7+
"dependencies": {
8+
"react": "16.8.6",
9+
"react-dom": "16.8.6",
10+
"react-scripts": "3.2.0"
11+
},
12+
"devDependencies": {
13+
"typescript": "3.3.3"
14+
},
15+
"scripts": {
16+
"start": "react-scripts start",
17+
"build": "react-scripts build",
18+
"test": "react-scripts test --env=jsdom",
19+
"eject": "react-scripts eject"
20+
},
21+
"browserslist": [
22+
">0.2%",
23+
"not dead",
24+
"not ie <= 11",
25+
"not op_mini all"
26+
]
27+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>React App</title>
5+
<link rel="stylesheet" href="styles.css" />
6+
</head>
7+
8+
<body>
9+
<div id="root"></div>
10+
<script src="../src/index.js" type="text/jsx"></script>
11+
</body>
12+
</html>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
body {
2+
font: normal 14px/100% "Andale Mono", AndaleMono, monospace;
3+
color: #fff;
4+
padding: 50px;
5+
width: 300px;
6+
margin: 0 auto;
7+
background-color: #374954;
8+
text-align: center;
9+
}
10+
11+
h1 {
12+
font-size: 100px;
13+
}
14+
15+
.container {
16+
margin: 60% auto;
17+
}
18+
19+
button {
20+
display: inline;
21+
background-color: #6bbe92;
22+
border: 0;
23+
border-radius: 10px;
24+
box-shadow: 5px;
25+
margin: 10px;
26+
text-align: center;
27+
color: #fff;
28+
font-weight: bold;
29+
font-size: 50px;
30+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from "react";
2+
3+
function App() {
4+
return (
5+
<div className="container">
6+
<h1>TIME</h1>
7+
<button>Get Time</button>
8+
</div>
9+
);
10+
}
11+
12+
export default App;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from "react";
2+
import ReactDOM from "react-dom";
3+
import App from "./components/App";
4+
5+
ReactDOM.render(<App />, document.getElementById("root"));
6+
7+
//Challenge:
8+
//1. Given that you can get the current time using:
9+
let time = new Date().toLocaleTimeString();
10+
console.log(time);
11+
//Show the latest time in the <h1> when the Get Time button
12+
//is pressed.
13+
14+
//2. Given that you can get code to be called every second
15+
//using the setInterval method.
16+
//Can you get the time in your <h1> to update every second?
17+
18+
//e.g. uncomment the code below to see Hey printed every second.
19+
// function sayHi() {
20+
// console.log("Hey");
21+
// }
22+
// setInterval(sayHi, 1000);

0 commit comments

Comments
 (0)