Skip to content Skip to sidebar Skip to footer

Arrow Functions Inside Map In Render. React

I'd like to know if there is any performance difference between passing an arrow function to a map function inside render, and passing a reference to that arrow function, like so:

Solution 1:

Decoupling the function from the render method is pragmatically better and makes for a better functional approach. Although you are entirely correct in your way of thinking about the consumed resources of the initial approach there are different sides to this. The initial approach gets created at runtime, stored and mapped as a N of reference in the runtime compiler, optimized. Dare i assume V8. This happens because of the named function expression as opposed to an anonymous. I would advise you to keep the code functional, avoiding any creation of functions inside of render if possible, keep the abstraction at its most natural place.


Post a Comment for "Arrow Functions Inside Map In Render. React"