You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Code Quality: Refactor all React class components to functional components using hooks #22890
The official recommendation for writing React components is as follows.
All components should be implemented as function components, using hooks for managing component lifecycle and state.
If you're a new/junior contributor looking to help with this refactoring, follow these steps:
Search for class components on the codebase (For example by searching extends Component
Pick a component to refactor.
Comment on this issue saying that you're working on the said component.
Note This is a tracking issue for the React components guidelines. This issue is tailored specifically for junior and new contributors. Experienced contributors shouldn't do big refactorings unless they update the code for another reason (bug fix, feature).
Reacted by Ella, Mahesh Waghmare, Ajit Bohra, Clifford, Arun, Adam Bosco and Yash Jawale
Reacted by Yash Jawale, Tushar Bharti, Aditya Singh, Lakshyajeet Singh Goyal and Gautam Mehta
@c4rl0sbr4v0 Actually the Dashicon component is a bit special, it's one that is generated on a separate repository and injected here as is (not edited manually), I'd recommend working on another component if possible.
Hi! I would like to work on refactoring withFontSizes in packages/block-editor/src/components/font-sizes/with-font-sizes.js from its remaining class component to a function component using hooks, while preserving the existing HOC API and behavior.
I will keep the change scoped to this component and add focused regression coverage for the derived font-size values and setters.
I use AI assistance as part of my engineering workflow; I will review and validate the implementation myself and disclose the assistance in the PR according to the project guidelines.
Thanks everyone for contributing to this effort. The migration is mostly done. Only one or two items remain and they've PRs, just waiting for reviews.
Search might show cases that don't need refactoring and class components are used either for testing purposes or for backward compatibility. Error boundaries also have to remain class components.
I'm going to close this issue. If you have time please test/review linked open PRs.
Activity
pkvillanueva commentedon Jun 4, 2020
👋 I'm working on TabPanel component.
truchot commentedon Jun 4, 2020
I'm working on DatePicker component ;)
cbravobernal commentedon Jun 4, 2020
I'm working on Dashicon component :-)
torounit commentedon Jun 4, 2020
I'm working on ImageSizeControl component.
youknowriad commentedon Jun 4, 2020
@c4rl0sbr4v0 Actually the Dashicon component is a bit special, it's one that is generated on a separate repository and injected here as is (not edited manually), I'd recommend working on another component if possible.
cbravobernal commentedon Jun 4, 2020
Question about refactoring components: should we use
function Name () {}or an arrow function ->const Name = () => {}?In order to have all more or less the same structure :-)
truchot commentedon Jun 4, 2020
I use
function Name() {}for components and arrow function inside. I don't know if I do well.pkvillanueva commentedon Jun 4, 2020
@c4rl0sbr4v0 I think both are fine to use.
youknowriad commentedon Jun 4, 2020
We don't have a defined guideline, I think we prefer
function Namein general but @truchot's way is a good middle ground too.cbravobernal commentedon Jun 4, 2020
I took Dropdown, this is not an easy one 😆
truchot commentedon Jun 4, 2020
@c4rl0sbr4v0 : It seems named functions are more appreciated than arrow functions 😄
I understand it's more convenient to debug.
ellatrix commentedon Jun 5, 2020
It's especially good to refactor the blocks since that code is the most looked at and copied.
43 remaining items
Refactor NavigableContainer from class to function component
Refactor NavigableContainer from class to function component
Components: Refactor NavigableContainer from class to function compon…
Components: Refactor NavigableContainer from class to function compon…
Components: Refactor withFallbackStyles from class to function component
rushikeshmore commentedon May 31, 2026
Converted
withFallbackStylesto a function component with hooks in #78837.Components: Refactor withFallbackStyles from class to function component
sajjadfaraj-dev commentedon Aug 3, 2026
Hi! I would like to work on refactoring
withFontSizesinpackages/block-editor/src/components/font-sizes/with-font-sizes.jsfrom its remaining class component to a function component using hooks, while preserving the existing HOC API and behavior.I will keep the change scoped to this component and add focused regression coverage for the derived font-size values and setters.
I use AI assistance as part of my engineering workflow; I will review and validate the implementation myself and disclose the assistance in the PR according to the project guidelines.
aadil42 commentedon Aug 14, 2026
I'd like to refactor
MediaUploadModalWrapperinpackages/editor/src/hooks/media-upload.jsfrom class component to a functional component.This component only uses state to track
isOpenstate which we can be refactor with simpleuseStateI have added tests as well.
Thank you.
Mamaduka commentedon Aug 18, 2026
Thanks everyone for contributing to this effort. The migration is mostly done. Only one or two items remain and they've PRs, just waiting for reviews.
Search might show cases that don't need refactoring and class components are used either for testing purposes or for backward compatibility. Error boundaries also have to remain class components.
I'm going to close this issue. If you have time please test/review linked open PRs.