arrow function in render method antipattern in examples
Closed this issue · 4 comments
You should not create arrow functions in render methods, it's recreated at every render, giving extra job for the garbage collector. One way to deal with it is to define the arrow function as a member of the class.
thanks for the feedback.
the use of arrow functions is intentional. my goal in each of these examples is to provide the minimum-viable example. it's true that it could become a performance bottleneck in the wrong scenario. however, that's not guarantee and it makes the example code much more complex.
👍 agreed, but for beginners it would be a useful comment
@vujevits i agree that it would be helpful info. is there an article that you might recommend adding on the topic?
Sure, this one was a general on performance, and touches the topic:
http://benchling.engineering/performance-engineering-with-react/