Any benefit to changing volto components to be functional?

I find myself converting shadowed components from component-based components to functional components before making any adjustments to them (to make it easier to see what is being changed in the shadow). Would some PRs to Volto changing existing class-based components to functional be beneficial to attract new React developers, or is there the expectation there for devs to be comfortable using both?

Based on the reality of today's Volto codebase of mixed class/functional, I think the expectation is that React developers are comfortable with both. Typically new Volto code is written in functional style, so probably classes will be gradually phased out, as the code gets touched. There's no dirrected effort in rewriting classes to functional, but if anyone wants to contribute to this, their help would be greatly appreciated.

2 Likes

Considering Facebook is officially encouraging developers to use functions instead of classes for optimisation reasons, I would say that this is clearly the way to go. Functions, and hooks.

Personally, between 2019 and 2021, I've reduced my toolchain from (class-based React components + Redux + Redux-thunk) to (functional React components), my codebase is tremendously shorter and so much simpler to understand (especially by myself ;)). I'm never going back. Incidentally, I've also adopted SWR, a great tool.

1 Like

Reference?

What about this?

and especiallty the section Classes confuse both people and machines.

Hope this helps,

Laurent.

Plone Foundation Code of Conduct