Skip to content

Instantly share code, notes, and snippets.

@darotar
Last active January 15, 2019 18:53
Show Gist options
  • Save darotar/6f918d2c9dbbc13c4d022dc7a56425a5 to your computer and use it in GitHub Desktop.
Save darotar/6f918d2c9dbbc13c4d022dc7a56425a5 to your computer and use it in GitHub Desktop.

FE Code Review Check-list

  • trackBy attribute for template loops

    Why?

    When an array changes, Angular re-renders the whole DOM tree. But if you use trackBy, Angular will know which element has changed and will only make DOM changes for that particular element.

    Bad

    <li *ngFor="let item of items;">{{ item }}</li>

    Good

    /* in the template */
    <li *ngFor="let item of items; trackBy: trackByFn">{{ item }}</li>

    /* in the component */
    trackByFn(index, item) {return item.id;}

1) trackBy for loops
2) const vs let
3) RxJS pipeable operators
4) subscribing in template with async
5) Don't forget to destroy subscriptions (with takeUntil)
6) Use right *Map rxjs operator
7) If this is new route component, it must be lazy loaded
8) No subscriptions inside of subscriptions (use another rxjs operators)
9) Never use type 'any'
10) No magic numbers and no console.[anything] commands
11) Make component as dumb as possible
12) Don't repeat the same code and funcitons
13) Don't make logic in templates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment