-
Notifications
You must be signed in to change notification settings - Fork 393
Commit ec6ca50
fix: use class method since the constructor is binding
The arrow function syntax on a class property will create a new function bound to every instance of the App class that is made. So if you had 1000 App components rendered to the screen we would have 1000 copies of the same function each bound to their own instance.
The `.bind(this)` in the constructor takes a class method and binds it to the prototype, this means the 1000 apps each get the same reference to the single function that was created on the object prototype.
In this PR I change filterTips to a non-arrow function because it doesn't make sense to bind a class property arrow function. I haven't seen the videos, but if you wanted to demonstrate arrow functions then an alternate version of this PR would be to remove the `.bind(this)` call from the constructor for `filterTips` and leave it as an arrow function.1 parent e3a5d02 commit ec6ca50
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | - | ||
81 | + | ||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
0 commit comments