Saying inline functions in render is bad is like correcting somebody who said "who" to say "whom" when "who" was actually correct.
-
-
I think the ember equivalent would be https://guides.emberjs.com/v2.15.0/components/block-params/ …. Rather than child nodes, you component gets a fn to call with args
-
There's no direct equivalent of ^ in React, because no this.props.children(args)
-
No, not a direct equivalent, but I think the purpose of render functions it to achieve the a similar end results
-
Isn't it mostly used for callbacks a la ember actions?
-
I've got a write up coming, but yeah, it's usually click handler type things that aren't even relevant to rendering.
-
Seems fine to inline simple ones, especially () => this.something(something)
-
Even Ember, which on balance has less logic in our render() (templates) than react has an inline action thing.
-
modern ember probably different, but I struggled to keep required referential model identity. People are opting into that and don't need to.
- 9 more replies
New conversation -
-
-
Stuff like <Thing onClick={() => this.setState(...)} /> In render gets called out for being bad for perf. Creating new funcs every render.
-
Breaks shouldComponentUpdate, PureComponent's strict equality checks, but lots of devs never use those in the first place.
-
Ok. I think it's probably more of a readability and maintainability hazard in some cases, but "no inline funcs" is like saying "no use of +"
-
I think the problem is that it defeats the JIT and leads to more allocation/GC.
-
Stuff you do in your own components is almost never the hot path. I don't want to say never but it's basically never.
-
I've seen some people argue that this is related to the method living on the prototype vs the instance? Would that affect performance?
-
In the case of “actions”/event listeners though, you’d still need to bind() per instance. Presumably this case can be optimized by VMs.
-
…and I suppose VMs could optimize the same function being created in the same spot over and over, too.
- 4 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.