4 ms·
We're still working on our own first truly large scale React application, and while we haven't seen significant memory pressure from inline functions, I still t
by arenaninja 9y ago
We're still working on our own first truly large scale React application, and while we haven't seen significant memory pressure from inline functions, I still think it makes it harder to debug
I was trying to fix a focus issue on a component so I hooked in to componentWillUpdate to see what was happening, and it was ridiculously noisy. I added a function to diff the state and props objects and most of the time the only changes were the inlined functions. I removed the inlining and I could debug again as only 4 diffs occurred and they were actual props/state changes, hooray!
It may be that there's zero performance gain from avoiding them, but when you work with a large complex application any time you can save debugging is a blessing. I may not avoid inlined functions wholesale now, but I will definitely do so for complex components where they will need to be debugged
- marcosdumay 9y agoThat is a problem of emulating functional behavior in a language that is not functional at its core. In functional languages you mostly don't debug, you reconstruct your functions in a controlled environment while you look at the intermediate results. That works everywhere except on a tiny effectfull portion of your code, where you have to actually debug like the imperative code that it is. In Javascript that effectfull portion is usually all the code, and even the places that could be reconstructed at will you will have to debug first to be sure they haven't side effects.
- arenaninja 9y agoFunny that you mention this, because part of the problem was that someone had made a fully functional wrapper around the component. Someone else made a second class wrapper around the functional one because the component has text so state is needed. I wrote out the functional wrapper entirely and kept maybe one of the functions in the class wrapper Now I think a great many things can be made functional in JavaScript, but purists ruin this for everyone else.
- marcosdumay 9y agoWe seem to be defining those words differently. From my position, it's impossible to create a pure wrapper for an interface widget.