Skip to content

Commit c78953b

Browse files
committed
Improve function naming
1 parent 6a3c28e commit c78953b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

1-exercise-solutions/lesson-04/4b.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
function App() {
2525
const [isButtonOn, setIsButtonOn] = React.useState(true);
2626

27-
function switchButtonOn() {
27+
function toggleButton() {
2828
// Another solution is: setIsButtonOn(!isButtonOn);
2929
if (isButtonOn) {
3030
setIsButtonOn(false);
@@ -36,7 +36,7 @@
3636
return (
3737
<button
3838
className="on-button"
39-
onClick={switchButtonOn}
39+
onClick={toggleButton}
4040
>
4141
{isButtonOn ? 'ON' : 'OFF'}
4242
</button>

1-exercise-solutions/lesson-04/4c.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
function App() {
3434
const [isButtonOn, setIsButtonOn] = React.useState(true);
3535

36-
function switchButtonOn() {
36+
function toggleButton() {
3737
if (isButtonOn) {
3838
setIsButtonOn(false);
3939
} else {
@@ -48,7 +48,7 @@
4848
return (
4949
<button
5050
className={isButtonOn ? 'on-button' : 'off-button'}
51-
onClick={switchButtonOn}
51+
onClick={toggleButton}
5252
>
5353
{isButtonOn ? 'ON' : 'OFF'}
5454
</button>

0 commit comments

Comments
 (0)