As I’ve been working on some more apps I’ve been starting to notice that I need to be reminded about which type of function to use. The ever effective compiler error. The computer not knowing what “this” is and me assuming I knew what this was. Always a good recipe for disaster. I realize the mistake right away after seeing the error message, but it would be nice to not see the error message in the first place.
Usually when I make these apps I have some functional components and class components. I end up writing a function correctly for the functional component and then having to change it ever so slightly for the class component. That is probably why I’m leading more towards functional components, but I should know why there are differences in the first place.
While trying to be hip I guess? I’ve been using a lot of arrow functions. The way I was writing the arrow function in my class component wasn’t allowing the function to refer to a this outside of the function. I needed to do something more like this…
I would normally try to write the function without the equal sign. Depending on the situation I would write functions a couple different ways. I only encounter some problems while in the class components. What I gathered from the documentation is that arrow functions were not made for “this”