3 ms·
His example: const withDagobah = PlanetViewComponent => class extends React.Component { ... } } Seems as if it would be pretty bad
by christophilus 9y ago
His example:
const withDagobah = PlanetViewComponent =>
class extends React.Component {
...
}
}
Seems as if it would be pretty bad from a perf perspective. It's defining a class every time that function is called. Anyone familiar with the dark underside of JavaScript care to comment?
- kitd 9y agoA class is just a constructor function (in this case the function is a React component), so it is a function returning a function, which is a fairly common activity.
- PuercoPop 9y agoIt is only going to be called once (per componented used in) upon loading the page. No biggie
- boubiyeah 9y agoIt's evaluated once at script parsing/evaluation time so it's not really expensive.