Closed Bug 1409064 Opened 7 years ago Closed 7 years ago

Network Monitor needs to use ES6 classes so that we can switch it over to PureComponent

Categories

(DevTools :: Netmonitor, enhancement, P2)

enhancement

Tracking

(firefox57 fix-optional, firefox58 fixed)

RESOLVED FIXED
Firefox 58
Tracking Status
firefox57 --- fix-optional
firefox58 --- fixed

People

(Reporter: miker, Assigned: miker)

References

Details

Attachments

(1 file, 1 obsolete file)

jlast pointed me at https://github.com/reactjs/react-codemod that can help automate these changes.
The codemod jlast pointed me at uses ES6 class arrow functions, static properties and a bunch of other features that are currently only supported by babel. I have made significant changes to the AST to get it working with our code base but I think it is fine... at least, after converting the Network Monitor it still seems to work fine.
try is green so asked Honza for review.
@Mike: The patch needs to be rebased. unable to find 'devtools/client/netmonitor/src/components/headers-panel.js' for patching 4 out of 4 hunks FAILED -- saving rejects to file devtools/client/netmonitor/src/components/headers-panel.js.rej unable to find 'devtools/client/netmonitor/src/components/monitor-panel.js' for patching 4 out of 4 hunks FAILED -- saving rejects to file devtools/client/netmonitor/src/components/monitor-panel.js.rej unable to find 'devtools/client/netmonitor/src/components/properties-view.js' for patching 5 out of 5 hunks FAILED -- saving rejects to file devtools/client/netmonitor/src/components/properties-view.js.rej unable to find 'devtools/client/netmonitor/src/components/request-list-column-cause.js' for patching 2 out of 2 hunks FAILED -- saving rejects to file devtools/client/netmonitor/src/components/request-list-column-cause.js.rej unable to find 'devtools/client/netmonitor/src/components/request-list-column-content-size.js' for patching etc.. The file-names changed. E.g. headers-panel.js => HeadersPanel.js (to follow CamelCase standard for React component files) Honza
No problem... the network panel was converted in less than 10 seconds so I can recreate the patch any time.
Comment on attachment 8920156 [details] Bug 1409064 - Network Monitor swith to ES6 classes https://reviewboard.mozilla.org/r/191124/#review197108 ::: devtools/client/netmonitor/src/components/headers-panel.js:276 (Diff revision 1) > ) > ); > } > -}); > +} > + > +HeadersPanel.displayName = "HeadersPanel"; displayName is useless after converting to ES6 Classes. Please remove it. https://reactjs.org/docs/react-component.html#displayname ::: devtools/client/netmonitor/src/components/headers-panel.js:278 (Diff revision 1) > } > -}); > +} > + > +HeadersPanel.displayName = "HeadersPanel"; > + > +HeadersPanel.propTypes = { Can we move propType into Component and use static prop instead? class HeadersPanel extends Component { static defaultProp = { ... }; static propTypes = { ... }; } Plus, we can also define `state` out of constructor like this: class HeadersPanel extends Component { state = { ... }; }
Comment on attachment 8920156 [details] Bug 1409064 - Network Monitor swith to ES6 classes https://reviewboard.mozilla.org/r/191124/#review197108 > displayName is useless after converting to ES6 Classes. Please remove it. > > https://reactjs.org/docs/react-component.html#displayname It isn't needed when using createClass() either. We can't remove it without the team agreeing that we will no longer use it so I have created an RFC: https://github.com/devtools-html/rfcs/issues/25 > Can we move propType into Component and use static prop instead? > > > class HeadersPanel extends Component { > static defaultProp = { > ... > }; > > static propTypes = { > ... > }; > } > > Plus, we can also define `state` out of constructor like this: > > class HeadersPanel extends Component { > state = { > ... > }; > } > Can we move propType into Component and use static prop instead? > > class HeadersPanel extends Component { > static defaultProp = { > ... > }; > > static propTypes = { > ... > }; > } No, the majority of our code is not transpiled and class properties are not part of ES7. From what I understand, this is because static getters are supported. I have changed the AST transformer to use static getters instead. > Plus, we can also define state out of constructor like this: > > class HeadersPanel extends Component { > state = { > ... > }; > } Again, class properties are not part of ES7 so we can't do that.
Attachment #8920156 - Attachment is obsolete: true
Attachment #8920156 - Flags: review?(odvarko)
Comment on attachment 8921435 [details] Bug 1409064 - Network Monitor to ES6 classes https://reviewboard.mozilla.org/r/192464/#review198082 I like the patch, thanks Mike! R+ assuming try is green. Honza
Attachment #8921435 - Flags: review?(odvarko) → review+
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 58
Blocks: 1411904
No longer depends on: 1411904
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: