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:
extends 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).
馃憢 I'm working on TabPanel component.
I'm working on DatePicker component ;)
I'm working on Dashicon component :-)
I'm working on ImageSizeControl component.
@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.
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 :-)
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 :-)
I use function Name() {}
for components and arrow function inside. I don't know if I do well.
@c4rl0sbr4v0 I think both are fine to use.
We don't have a defined guideline, I think we prefer function Name
in general but @truchot's way is a good middle ground too.
I took Dropdown, this is not an easy one 馃槅
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 :-)
@c4rl0sbr4v0 : It seems named functions are more appreciated than arrow functions 馃槃
I understand it's more convenient to debug.
It's especially good to refactor the blocks since that code is the most looked at and copied.
If I work on refactoring the ColorPicker
component, should I include its sub-components Alpha, Hue, Inputs, and Saturation?
@pkvillanueva not necessarily, you can do one by one.
I'm working on the PanelBody
component
PR ready for Media & Text ~https://github.com/WordPress/gutenberg/pull/23062~ https://github.com/WordPress/gutenberg/pull/23102
PR for CalendarEdit #23072.
I'm working on Tag Cloud block.
I'm going to tackle Latest Comments block next. 馃憤
I'm tackling the Disabled component
I am working on the URLPopover component
MediaPlaceholder
here: https://github.com/WordPress/gutenberg/pull/23671
I'll tackle <BlockInvalidWarning>
馃挭
I'll tackle <TimePicker>
next 馃晲
I'm working on <BlockMover>
!
I will be working on the GalleryImage component
I'm working on the ColorPicker component.
Most helpful comment
It's especially good to refactor the blocks since that code is the most looked at and copied.