File tree 6 files changed +101
-26
lines changed
6 files changed +101
-26
lines changed Original file line number Diff line number Diff line change @@ -6,23 +6,27 @@ import Hello from './components/Hello';
6
6
import Message from './components/Message' ;
7
7
import Counter from './components/Counter'
8
8
import Setstate from './components/Setstate' ;
9
+ import FunctionClick from './components/FunctionClick' ;
10
+ import ClassClick from './components/ClassClick' ;
9
11
10
12
function App ( ) {
11
13
return (
12
14
< div className = "App" >
15
+
16
+ < FunctionClick />
17
+ < ClassClick />
18
+ { /* <Setstate/> */ }
19
+ { /* <Counter/> */ }
20
+ { /* <Message/> */ }
21
+ { /* { <Greet name="Bruce" heroName="Batman" />
22
+ <Greet name="Clark" heroName="Superman"/> */ }
23
+ { /* <Greet name="Diana" heroName="wonder Woman" /> */ }
13
24
14
- < Setstate />
15
-
16
- { /* <Counter/> */ }
17
- { /* <Message/> */ }
18
- { /* <Greet name="Bruce" heroName="Batman" />
19
- <Greet name="Clark" heroName="Superman"/>
20
- <Greet name="Diana" heroName="wonder Woman" />
21
-
22
- < Welcome name="Bruce" heroName="Batman" />
23
- < Welcome name="Clark" heroName="Superman"/>
24
- < Welcome name="Diana" heroName="wonder Woman" /> */ }
25
- { /* <Hello/> */ }
25
+ { /* < Welcome name="Bruce" heroName="Batman" /> */ }
26
+
27
+ { /* < Welcome name="Clark" heroName="Superman"/>
28
+ < Welcome name="Diana" heroName="wonder Woman" /> */ }
29
+ { /* <Hello/> */ }
26
30
</ div >
27
31
) ;
28
32
}
Original file line number Diff line number Diff line change
1
+ import React , { Component } from 'react'
2
+
3
+ class ClassClick extends Component {
4
+
5
+ // METHOD
6
+
7
+ clickHandler ( ) {
8
+ console . log ( 'Clicked the button' )
9
+ }
10
+
11
+
12
+
13
+ render ( ) {
14
+ return (
15
+ < div >
16
+ < button onClick = { this . clickHandler } > Click me</ button >
17
+ </ div >
18
+ )
19
+ }
20
+ }
21
+
22
+ export default ClassClick
23
+
24
+
Original file line number Diff line number Diff line change @@ -6,16 +6,22 @@ constructor(props) {
6
6
super ( props )
7
7
8
8
this . state = {
9
- count : 0 ,
10
- name : ''
9
+ count : 0
10
+
11
11
}
12
12
}
13
13
14
14
increment ( ) {
15
- const updatedCount = this . state . count + 1 ;
16
- this . setState ( { count : updatedCount } ) ;
15
+ this . setState ( {
16
+ count : this . state . count + 1
17
+ } ,
18
+ ( ) => {
19
+ console . log ( 'Callback value' , this . state . count )
20
+ }
17
21
18
- console . log ( updatedCount ) ;
22
+ ) ;
23
+
24
+ console . log ( this . state . count ) ;
19
25
}
20
26
21
27
render ( ) {
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+
3
+ function FunctionClick ( ) {
4
+
5
+ function clickHandler ( ) {
6
+ console . log ( 'Button clicked' )
7
+ }
8
+
9
+ return (
10
+ < div >
11
+ < button onClick = { clickHandler } > Click</ button >
12
+ </ div >
13
+ )
14
+ }
15
+
16
+ export default FunctionClick
Original file line number Diff line number Diff line change 2
2
3
3
class Welcome extends Component {
4
4
render ( ) {
5
+ const { name, heroName} = this . props
6
+ // const {state1, state2}= this.state
5
7
return (
6
8
< h1 >
7
- Welcome { this . props . name } a.k.a { this . props . heroName }
9
+ Welcome { name } a.k.a { heroName }
8
10
</ h1 >
9
11
10
12
) ;
Original file line number Diff line number Diff line change @@ -6,11 +6,34 @@ import React from 'react';
6
6
// );
7
7
// }
8
8
9
- export const Greet = props => {
10
- console . log ( props ) ;
11
- return (
12
- < h1 > Hello { props . name } a.k.a { props . heroName } </ h1 >
13
- ) ;
14
- }
15
-
16
- // export default Greet;
9
+ // // export const Greet = ({name,heroName}) => {
10
+
11
+ // // return(
12
+ // // <div>
13
+ // // <h1>
14
+ // // Hello {name} a.k.a {heroName}
15
+ // // </h1>
16
+ // // </div>
17
+ // // );
18
+ // }
19
+
20
+ export const Greet = props => {
21
+ const { name , heroName} = props
22
+ return (
23
+ < div >
24
+ < h1 >
25
+ Hello { name } a.k.a { heroName }
26
+ </ h1 >
27
+ </ div >
28
+ ) ;
29
+ }
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
You can’t perform that action at this time.
0 commit comments