Skip to content

Commit 8b1cf33

Browse files
update app
1 parent 70fd404 commit 8b1cf33

File tree

1 file changed

+20
-1
lines changed
  • project-1/project-app/src/components

1 file changed

+20
-1
lines changed

project-1/project-app/src/components/About.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff 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>

0 commit comments

Comments
 (0)