Created
April 9, 2020 08:51
-
-
Save tonkotsuboy/2efc6c6146b327fe5147215edc920cb7 to your computer and use it in GitHub Desktop.
event.target しか使わない関数の定義方法について思っていること。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // event.targetしか使わない関数 | |
| // ちょっと冗長かも🤮 | |
| const foo = (event: MouseEvent) => { | |
| if (event.target == null) { | |
| return; | |
| } | |
| console.log(event.target); | |
| }; | |
| // すっきり🥰 | |
| const bar = ({ target }: MouseEvent) => { | |
| if (target == null) { | |
| return; | |
| } | |
| console.log(target); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment