plone / volto

React-based frontend for the Plone Content Management System
https://demo.plone.org/
MIT License
433 stars 578 forks source link

Refactor class components to functional components #4460

Open sneridagh opened 1 year ago

sneridagh commented 1 year ago

PLIP (Plone Improvement Proposal)

Responsible Persons

Proposer: Víctor Fernández de Alba (@sneridagh)

Seconder:

Abstract

Refactor all the possible components in Volto that still are class-based components. Convert them to functional components, whenever possible.

Motivation

Volto still have a number of core components that are React class-based components. This prevents the use of hooks in them, and newest DX on them.

The idea is also while moving to them, use hooks to abstract the functionality present in Redux and in data fetching so in a near future we can easily switch using the hooks to use other props provider.

Assumptions

No assumptions.

Proposal & Implementation

Refactor should be done carefully and providing Cypress (acceptance) tests where they do not exist. The lifecycle of the components should be preserved while watching out for edge cases and UX problems.

Deliverables

It should be delivered all at once, as a major breaking change. Ideally, we won't change the contract of any of the components, so no new props passed down, no return anything to the tree that we were not returning before, unless it's justified.

If the contract has to be broken, then it must be properly documented and exposed in the upgrade guide.

The refactored components. Here there is a preliminary list, subject to change:

Complex / Optional:

Risks

The lifecycle of a component could easily be changed if the refactor is not done carefully and giving attention to details, that's why we should provide acceptance tests and heavy QA should be done while doing it.

Participants

Víctor Fernández de Alba (@sneridagh) Anyone who would like to help and take over, will be appreciated.

sneridagh commented 1 year ago

To all GSOC aspirants: https://community.plone.org/t/recommendations-for-gsoc-aspirants/16301/3

/cc @sudhanshu1309

tisto commented 4 months ago

@sneridagh what Plone version is this feature planned for?

sneridagh commented 4 months ago

@tisto This is an ongoing effort. Tisha worked on this during her GSOC. The reach was too broad, so we had to cut it down. This can be presented again in the next GSOC for continuation of the work.

The ones reviewed and merged (during 17 alpha phase) were released in Volto 17.

In the meanwhile, there are still some PRs opened (one per component). These are merged in alpha stages, because they are considered breaking. AFAIK, the project is stalled right now.