diff --git a/docs/code_style.md b/docs/code_style.md index 154ec039..d8f458d7 100644 --- a/docs/code_style.md +++ b/docs/code_style.md @@ -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... + } +} +``` \ No newline at end of file