Skip to content

Commit acae3f0

Browse files
authored
Merge pull request #4019 from meeroslaph/patch-3
Suggest further optimization example for Button component refactoring
2 parents 11fc921 + 7f41dd0 commit acae3f0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/content/1/en/part1c.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,4 +737,12 @@ const Button = ({ onClick, text }) => (
737737
)
738738
```
739739
740+
Or, similar to the Display example, you can further optimize the Button component to a single line by removing the parentheses and formatting it as follows:
741+
742+
```js
743+
const Button = ({ onClick, text }) => <button onClick={onClick}>{text}</button>
744+
```
745+
746+
This approach works because the component contains only a single return statement, making it possible to use the concise arrow function syntax.
747+
740748
</div>

0 commit comments

Comments
 (0)