Last active
June 9, 2021 04:18
-
-
Save itsMapleLeaf/23dbfd30765c0bc9a64050d3aa02184a to your computer and use it in GitHub Desktop.
js arrow function syntax
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
| // good | |
| items.map(item => { | |
| return <div /> | |
| }) | |
| // good - implicit return, doesn't require curly braces {} or return keyword | |
| items.map(item => <div />) | |
| // good - using parens when on multiple lines is a common convention | |
| items.map(item => ( | |
| <div /> | |
| )) | |
| // bad - when using curly braces, a return is needed | |
| // here, the div just gets ignored and you map to an array full of `undefined`s | |
| items.map(item => { | |
| <div /> | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment