Skip to content

Commit

Permalink
updated code style with class property style
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroX-DG committed Oct 27, 2018
1 parent 6cb6cd3 commit 4550d88
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/code_style.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,25 @@ const isSecondMarkdownNote = note.type == 'markdown' && note.index == 2
const isNoteHasString = note.content.indexOf('string') != -1
if (isSecondMarkdownNote && isNoteHasString)
```

### Use class property instead of class methods
When writing React components, try to use class property instead of class methods. The reason for this is explained perfectly here:
https://codeburst.io/use-class-properties-to-clean-up-your-classes-and-react-components-93185879f688

**Example**:

```js
// BAD
class MyComponent extends React.Component {
myMethod () {
// code goes here...
}
}

// GOOD
class MyComponent extends React.Component {
myMethod = () => {
// code goes here...
}
}
```

0 comments on commit 4550d88

Please sign in to comment.