3 ms·
I don't think it's a concerns issue. You can simply decide to never create functions in any render(). There's even an eslint rule for it.
by always_good 8y ago
I don't think it's a concerns issue. You can simply decide to never create functions in any render(). There's even an eslint rule for it.
- yunyu 8y agoThe rationale behind that is avoiding re-renders, which can (but doesn't always) improve performance (shouldComponentUpdate can be slower than simply always re-rendering, per a React core developer): https://news.ycombinator.com/item?id=14418576 https://news.ycombinator.com/item?id=14418576 If you're concerned about allocation, here's what the same core developer has to say about inline functions in render(): https://twitter.com/sophiebits/status/938075351414063104?lang=en https://twitter.com/sophiebits/status/938075351414063104?lan... Also see the article that acemarke linked above. This is a textbook case of premature optimization. Why make your code harder to read just to achieve some performance gains that likely aren't even noticeable? Lastly, regarding the ESLint rule, sophiebits put it better than I can: I don’t recall ever having seen a credible-looking study about this, including in 2015.