Replace lodash with built-ins where possible to reduce bundle size (#1766)

* add tslint rule to disallow lodash.isUndefined

* add tslint rule to disallow lodash.isNull

* apply fixes
This commit is contained in:
Xianny
2019-04-10 09:36:32 -07:00
committed by GitHub
parent 49d951b7be
commit 7423028fea
299 changed files with 1249 additions and 1038 deletions

View File

@@ -58,27 +58,28 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
clearTimeout(this._wikiBackoffTimeoutId);
}
public render(): React.ReactNode {
const sectionNameToLinks = _.isUndefined(this.state.articlesBySection)
? {}
: this._getSectionNameToLinks(this.state.articlesBySection);
const sectionNameToLinks =
this.state.articlesBySection === undefined ? {} : this._getSectionNameToLinks(this.state.articlesBySection);
const mainContent = _.isUndefined(this.state.articlesBySection) ? (
<div className="flex justify-center">{this._renderLoading()}</div>
) : (
<div id="wiki" style={{ paddingRight: 2 }}>
{this._renderWikiArticles()}
</div>
);
const mainContent =
this.state.articlesBySection === undefined ? (
<div className="flex justify-center">{this._renderLoading()}</div>
) : (
<div id="wiki" style={{ paddingRight: 2 }}>
{this._renderWikiArticles()}
</div>
);
const isSmallScreen = this.props.screenWidth === ScreenWidths.Sm;
const sidebar = _.isUndefined(this.state.articlesBySection) ? (
<div />
) : (
<NestedSidebarMenu
sidebarHeader={isSmallScreen ? this._renderSidebarHeader() : undefined}
sectionNameToLinks={sectionNameToLinks}
screenWidth={this.props.screenWidth}
/>
);
const sidebar =
this.state.articlesBySection === undefined ? (
<div />
) : (
<NestedSidebarMenu
sidebarHeader={isSmallScreen ? this._renderSidebarHeader() : undefined}
sectionNameToLinks={sectionNameToLinks}
screenWidth={this.props.screenWidth}
/>
);
return (
<DevelopersPage
sidebar={sidebar}