File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
project-1/project-app/src/components Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,25 @@ export default function About() {
66 color : 'white' ,
77 backgroundColor : 'black'
88 } )
9+
10+ const [ btntext , setBtntext ] = useState ( "Enable light Mode" )
11+
12+ const toggleStyle = ( ) => {
13+ if ( myStyle . color == 'white' ) {
14+ setMyStyle ( {
15+ color : 'black' ,
16+ backgroundColor : 'white'
17+ } )
18+ setBtntext ( "Enable dark Mode" ) ;
19+ }
20+ else {
21+ setMyStyle ( {
22+ color : 'white' ,
23+ backgroundColor : 'black'
24+ } )
25+ setBtntext ( "Enable light Mode" ) ;
26+ }
27+ }
928 return (
1029
1130 < >
@@ -51,7 +70,7 @@ export default function About() {
5170 </ div >
5271 </ div >
5372 < div className = "container" >
54- < button type = "button" className = "btn btn-primary my-3" > Enable dark mode </ button >
73+ < button onClick = { toggleStyle } type = "button" className = "btn btn-primary my-3" > { btntext } </ button >
5574 </ div >
5675 </ div >
5776 </ div >
You can’t perform that action at this time.
0 commit comments