1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

updated code style with class property style

This commit is contained in:
Nguyễn Việt Hưng
2018-10-27 09:47:15 +07:00
parent 6cb6cd3f26
commit 4550d888bb

View File

@@ -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...
}
}
```