Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Refactoring notes from feature/cleanup and address PR comments #566

Merged
merged 6 commits into from Jun 15, 2020
Next

Remove refactoring notes from feature/cleanup

  • Loading branch information
IAmThePan committed Jun 6, 2020
commit d966abd1de54a780770372516f02d7b2717f307a
@@ -26,18 +26,6 @@ import { updateSummaryBlockingCount } from '../utils/blocking';
class Blocking extends React.Component {
static contextType = DynamicUIPortContext;

/**
* Refactoring UNSAFE_componentWillMount into Constructor
* Stats:
* Constructor runtime before refactor: 0.038ms
* Constructor + UNSAFE_componentWillMount runtime before refactor: 0.333ms
* Constructor runtime after refactor: 0.129ms
*
* Notes:
* calling buildBlockingClasses and computeSiteNotScanned in the constructor takes 0.018ms.
*
* Conclusion: Refactor using constructor as the added computation is minimal
*/
constructor(props) {
super(props);

@@ -48,9 +48,6 @@ class BlockingHeader extends React.Component {

/**
* Lifecycle event
* Refactor Notes:
* Refactor UNSAFE_componentWillReceiveProps using getDerivedStateFromProps
* because we are only manipulating state.
*/
static getDerivedStateFromProps(prevProps, prevState) {
return BlockingHeader.updateBlockAll(prevProps.categories, prevState.fromHere);
@@ -27,20 +27,6 @@ import { renderKnownTrackerButtons, renderUnknownTrackerButtons } from './tracke
class Tracker extends React.Component {
static contextType = ThemeContext;

/**
* Refactoring UNSAFE_componentWillMount into Constructor
* Stats:
* Constructor runtime before refactor: 0.037ms
* Constructor + UNSAFE_componentWillMount runtime before refactor: 0.415ms
* Constructor runtime after refactor: 0.215ms
*
* Refactoring UNSAFE_componentWillMount into componentDidMount
* Stats:
* Constructor runtime after refactor: 0.020ms
* Constructor + componentDidMount runtime after refactor: 14.205ms
*
* Conclusion: Refactor using componentDidMount
*/
constructor(props) {
super(props);
this.state = {
@@ -22,23 +22,6 @@ import Rewards from '../containers/RewardsContainer';
* @memberOf PanelClasses
*/
class Detail extends React.Component {
/**
* Refactoring UNSAFE_componentWillMount into Constructor
* Stats:
* Constructor runtime before refactor: 0.085ms
* Constructor + UNSAFE_componentWillMount runtime before refactor: 0.345ms
* Constructor runtime after refactor: 0.163ms
*
* Refactoring UNSAFE_componentWillMount into componentDidMount
* Stats:
* Constructor runtime with no componentDidMount: 0.163ms
* Constructor runtime with componentDidMount: 0.078ms
* Constructor + componentDidMount runtime: 8.313ms
* Notes:
* Noticably slower when refactoring using componentDidMount
*
* Conclusion: Refactor using constructor
*/
constructor(props) {
super(props);

@@ -42,22 +42,6 @@ class Settings extends React.Component {
});
}, 3000)

/**
* Refactoring UNSAFE_componentWillMount into Constructor
* Stats:
* Constructor runtime before refactor: 0.145ms
* Constructor + UNSAFE_componentWillMount runtime before refactor: 0.330ms
* Constructor runtime after refactor: 0.144ms
*
* Refactoring UNSAFE_componentWillMount into componentDidMount
* Stats:
* Constructor runtime with no componentDidMount: 0.123ms
* Constructor runtime with componentDidMount: 0.147ms
*
* Notes: Negligible difference using componentDidMount.
*
* Conclusion: Refactor using constructor to avoid re-render
*/
constructor(props) {
super(props);
this.state = {
@@ -19,23 +19,6 @@ import moment from 'moment/min/moment-with-locales.min';
* @memberOf SettingsComponents
*/
class GeneralSettings extends React.Component {
/**
* Refactoring UNSAFE_componentWillMount into Constructor
* Stats:
* Constructor runtime before refactor: 0.026ms
* Constructor + UNSAFE_componentWillMount runtime before refactor: 2.410ms
* Constructor runtime after refactor: 1.631ms
*
* Refactoring UNSAFE_componentWillMount into componentDidMount
* Stats:
* Constructor runtime with no componentDidMount: 0.208ms
* Constructor runtime with componentDidMount: 0.074ms
*
* Notes:
* updateDbLastUpdated takes ~2ms to run the firt time and then 0.139ms subsequent times.
*
* Conclusion: Refactor using componentDidMount as to not do computations in the constructor
*/
constructor(props) {
super(props);
this.state = {
ProTip! Use n and p to navigate between commits in a pull request.