File tree Expand file tree Collapse file tree 5 files changed +103
-0
lines changed
react-usestate-hook-practice Expand file tree Collapse file tree 5 files changed +103
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change
1
+ body {
2
+ font : normal 14 px/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
+ }
Original file line number Diff line number Diff line change
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 ;
Original file line number Diff line number Diff line change
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);
You can’t perform that action at this time.
0 commit comments