fix: use class method since the constructor is binding #2
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
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 forfilterTips
and leave it as an arrow function.