use React.PureComponent

This commit is contained in:
Sean Yesmunt 2017-06-07 21:42:19 -07:00
parent 4c216d843b
commit e13d7c2149
41 changed files with 58 additions and 64 deletions

View file

@ -7,7 +7,7 @@ import UpgradeModal from "component/upgradeModal";
import lbry from "lbry";
import { Line } from "rc-progress";
class App extends React.Component {
class App extends React.PureComponent {
componentWillMount() {
document.addEventListener("unhandledError", event => {
this.props.alertError(event.detail);

View file

@ -10,7 +10,7 @@ import { CreditAmount, Address } from "../component/common.js";
import { getLocal, setLocal } from "../utils.js";
import rewards from "../rewards";
class SubmitEmailStage extends React.Component {
class SubmitEmailStage extends React.PureComponent {
constructor(props) {
super(props);
@ -94,7 +94,7 @@ class SubmitEmailStage extends React.Component {
}
}
class ConfirmEmailStage extends React.Component {
class ConfirmEmailStage extends React.PureComponent {
constructor(props) {
super(props);
@ -191,7 +191,7 @@ class ConfirmEmailStage extends React.Component {
}
}
class WelcomeStage extends React.Component {
class WelcomeStage extends React.PureComponent {
static propTypes = {
endAuth: React.PropTypes.func,
};
@ -323,7 +323,7 @@ const PendingStage = props => {
);
};
class CodeRequiredStage extends React.Component {
class CodeRequiredStage extends React.PureComponent {
constructor(props) {
super(props);
@ -417,7 +417,7 @@ class CodeRequiredStage extends React.Component {
}
}
export class AuthOverlay extends React.Component {
export class AuthOverlay extends React.PureComponent {
constructor(props) {
super(props);

View file

@ -2,7 +2,7 @@ import React from "react";
import lbry from "../lbry.js";
//component/icon.js
export class Icon extends React.Component {
export class Icon extends React.PureComponent {
static propTypes = {
icon: React.PropTypes.string.isRequired,
className: React.PropTypes.string,
@ -21,7 +21,7 @@ export class Icon extends React.Component {
}
}
export class TruncatedText extends React.Component {
export class TruncatedText extends React.PureComponent {
static propTypes = {
lines: React.PropTypes.number,
};
@ -42,7 +42,7 @@ export class TruncatedText extends React.Component {
}
}
export class BusyMessage extends React.Component {
export class BusyMessage extends React.PureComponent {
static propTypes = {
message: React.PropTypes.string,
};
@ -54,13 +54,13 @@ export class BusyMessage extends React.Component {
}
}
export class CurrencySymbol extends React.Component {
export class CurrencySymbol extends React.PureComponent {
render() {
return <span>LBC</span>;
}
}
export class CreditAmount extends React.Component {
export class CreditAmount extends React.PureComponent {
static propTypes = {
amount: React.PropTypes.number.isRequired,
precision: React.PropTypes.number,
@ -116,7 +116,7 @@ let addressStyle = {
fontFamily:
'"Consolas", "Lucida Console", "Adobe Source Code Pro", monospace',
};
export class Address extends React.Component {
export class Address extends React.PureComponent {
static propTypes = {
address: React.PropTypes.string,
};
@ -146,7 +146,7 @@ export class Address extends React.Component {
}
}
export class Thumbnail extends React.Component {
export class Thumbnail extends React.PureComponent {
static propTypes = {
src: React.PropTypes.string,
};

View file

@ -3,7 +3,7 @@ import { Modal } from "component/modal";
import { Line } from "rc-progress";
import Link from "component/link";
class DownloadingModal extends React.Component {
class DownloadingModal extends React.PureComponent {
render() {
const {
downloadProgress,

View file

@ -2,7 +2,7 @@ import React from "react";
import lbry from "lbry";
import { ExpandableModal } from "component/modal";
class ErrorModal extends React.Component {
class ErrorModal extends React.PureComponent {
render() {
const { modal, closeModal, error } = this.props;

View file

@ -1,7 +1,7 @@
import React from "react";
const { remote } = require("electron");
class FileSelector extends React.Component {
class FileSelector extends React.PureComponent {
static propTypes = {
type: React.PropTypes.oneOf(["file", "directory"]),
initPath: React.PropTypes.string,

View file

@ -7,7 +7,7 @@ import Link from "component/link";
import { ToolTip } from "component/tooltip";
import { DropDownMenu, DropDownMenuItem } from "component/menu";
class FileActions extends React.Component {
class FileActions extends React.PureComponent {
constructor(props) {
super(props);
this.state = {

View file

@ -6,7 +6,7 @@ import { Thumbnail, TruncatedText, Icon } from "component/common";
import FilePrice from "component/filePrice";
import UriIndicator from "component/uriIndicator";
class FileCard extends React.Component {
class FileCard extends React.PureComponent {
componentWillMount() {
this.resolve(this.props);
}

View file

@ -8,7 +8,7 @@ import rewards from "rewards.js";
import lbryio from "lbryio.js";
import { BusyMessage, Thumbnail } from "component/common.js";
class FileList extends React.Component {
class FileList extends React.PureComponent {
constructor(props) {
super(props);

View file

@ -47,7 +47,7 @@ const FileListSearchResults = props => {
return <div>{rows}</div>;
};
class FileListSearch extends React.Component {
class FileListSearch extends React.PureComponent {
componentWillMount() {
this.props.search(this.props.query);
}

View file

@ -1,7 +1,7 @@
import React from "react";
import { CreditAmount } from "component/common";
class FilePrice extends React.Component {
class FilePrice extends React.PureComponent {
componentWillMount() {
this.fetchCost(this.props);
}
@ -11,13 +11,7 @@ class FilePrice extends React.Component {
}
fetchCost(props) {
const {
costInfo,
fetchCostInfo,
uri,
fetching,
claim,
} = props;
const { costInfo, fetchCostInfo, uri, fetching, claim } = props;
if (costInfo === undefined && !fetching && claim) {
fetchCostInfo(uri);

View file

@ -7,7 +7,7 @@ import { Thumbnail, TruncatedText } from "component/common.js";
import FilePrice from "component/filePrice";
import UriIndicator from "component/uriIndicator";
class FileTile extends React.Component {
class FileTile extends React.PureComponent {
static SHOW_EMPTY_PUBLISH = "publish";
static SHOW_EMPTY_PENDING = "pending";

View file

@ -10,7 +10,7 @@ function formFieldId() {
return "form-field-" + ++formFieldCounter;
}
export class FormField extends React.Component {
export class FormField extends React.PureComponent {
static propTypes = {
type: React.PropTypes.string.isRequired,
prefix: React.PropTypes.string,
@ -164,7 +164,7 @@ export class FormField extends React.Component {
}
}
export class FormRow extends React.Component {
export class FormRow extends React.PureComponent {
static propTypes = {
label: React.PropTypes.oneOfType([
React.PropTypes.string,

View file

@ -3,7 +3,7 @@ import lbry from "../lbry.js";
import { BusyMessage, Icon } from "./common.js";
import Link from "component/link";
class LoadScreen extends React.Component {
class LoadScreen extends React.PureComponent {
static propTypes = {
message: React.PropTypes.string.isRequired,
details: React.PropTypes.string,

View file

@ -2,7 +2,7 @@ import React from "react";
import { Icon } from "./common.js";
import Link from "component/link";
export class DropDownMenuItem extends React.Component {
export class DropDownMenuItem extends React.PureComponent {
static propTypes = {
href: React.PropTypes.string,
label: React.PropTypes.string,
@ -32,7 +32,7 @@ export class DropDownMenuItem extends React.Component {
}
}
export class DropDownMenu extends React.Component {
export class DropDownMenu extends React.PureComponent {
constructor(props) {
super(props);

View file

@ -1,7 +1,7 @@
import React from "react";
import ReactModal from "react-modal";
export class ModalPage extends React.Component {
export class ModalPage extends React.PureComponent {
render() {
return (
<ReactModal

View file

@ -3,7 +3,7 @@ import ReactModal from "react-modal";
import Link from "component/link";
import app from "../app.js";
export class Modal extends React.Component {
export class Modal extends React.PureComponent {
static propTypes = {
type: React.PropTypes.oneOf(["alert", "confirm", "custom"]),
overlay: React.PropTypes.bool,
@ -64,7 +64,7 @@ export class Modal extends React.Component {
}
}
export class ExpandableModal extends React.Component {
export class ExpandableModal extends React.PureComponent {
static propTypes = {
expandButtonLabel: React.PropTypes.string,
extraContent: React.PropTypes.element,

View file

@ -1,6 +1,6 @@
import React from "react";
export class Notice extends React.Component {
export class Notice extends React.PureComponent {
static propTypes = {
isError: React.PropTypes.bool,
};

View file

@ -5,7 +5,7 @@ import Modal from "component/modal";
import rewards from "rewards";
import Link from "component/link";
export class RewardLink extends React.Component {
export class RewardLink extends React.PureComponent {
static propTypes = {
type: React.PropTypes.string.isRequired,
claimed: React.PropTypes.bool,

View file

@ -1,7 +1,7 @@
import React from "react";
import Link from "component/link";
class SnackBar extends React.Component {
class SnackBar extends React.PureComponent {
constructor(props) {
super(props);

View file

@ -2,7 +2,7 @@ import React from "react";
import lbry from "../lbry.js";
import LoadScreen from "./load_screen.js";
export class SplashScreen extends React.Component {
export class SplashScreen extends React.PureComponent {
static propTypes = {
message: React.PropTypes.string,
onLoadDone: React.PropTypes.func,

View file

@ -1,6 +1,6 @@
import React from "react";
export class ToolTip extends React.Component {
export class ToolTip extends React.PureComponent {
static propTypes = {
body: React.PropTypes.string.isRequired,
label: React.PropTypes.string.isRequired,

View file

@ -1,7 +1,7 @@
import React from "react";
import { Address, BusyMessage, CreditAmount } from "component/common";
class TransactionList extends React.Component {
class TransactionList extends React.PureComponent {
componentWillMount() {
this.props.fetchTransactions();
}

View file

@ -2,7 +2,7 @@ import React from "react";
import { Modal } from "component/modal";
import { downloadUpgrade, skipUpgrade } from "actions/app";
class UpgradeModal extends React.Component {
class UpgradeModal extends React.PureComponent {
render() {
const { downloadUpgrade, skipUpgrade } = this.props;

View file

@ -1,7 +1,7 @@
import React from "react";
import { Icon } from "component/common";
class UriIndicator extends React.Component {
class UriIndicator extends React.PureComponent {
componentWillMount() {
this.resolve(this.props);
}

View file

@ -5,7 +5,7 @@ import Modal from "component/modal";
import lbry from "lbry";
import { Thumbnail } from "component/common";
class VideoPlayButton extends React.Component {
class VideoPlayButton extends React.PureComponent {
onPurchaseConfirmed() {
this.props.closeModal();
this.props.startPlaying();
@ -92,7 +92,7 @@ class VideoPlayButton extends React.Component {
}
}
class Video extends React.Component {
class Video extends React.PureComponent {
constructor(props) {
super(props);
this.state = { isPlaying: false };
@ -182,7 +182,7 @@ const from = require("from2");
const player = require("render-media");
const fs = require("fs");
class VideoPlayer extends React.Component {
class VideoPlayer extends React.PureComponent {
componentDidMount() {
const elem = this.refs.media;
const { downloadPath, filename } = this.props;

View file

@ -2,7 +2,7 @@ import React from "react";
import Link from "component/link";
import { Address } from "component/common";
class WalletAddress extends React.Component {
class WalletAddress extends React.PureComponent {
componentWillMount() {
this.props.checkAddressIsMine(this.props.receiveAddress);
}

View file

@ -3,7 +3,7 @@ import lbryuri from "lbryuri";
import { BusyMessage } from "component/common";
import FileTile from "component/fileTile";
class ChannelPage extends React.Component {
class ChannelPage extends React.PureComponent {
componentDidMount() {
this.fetchClaims(this.props);
}

View file

@ -6,7 +6,7 @@ import Link from "../component/link";
const fs = require("fs");
const { ipcRenderer } = require("electron");
class DeveloperPage extends React.Component {
class DeveloperPage extends React.PureComponent {
constructor(props) {
super(props);

View file

@ -37,7 +37,7 @@ const FeaturedCategory = props => {
);
};
class DiscoverPage extends React.Component {
class DiscoverPage extends React.PureComponent {
componentWillMount() {
this.props.fetchFeaturedUris();
}

View file

@ -10,7 +10,7 @@ import { BusyMessage, Thumbnail } from "component/common.js";
import FileList from "component/fileList";
import SubHeader from "component/subHeader";
class FileListDownloaded extends React.Component {
class FileListDownloaded extends React.PureComponent {
componentWillMount() {
this.props.fetchFileInfosDownloaded();
}

View file

@ -10,7 +10,7 @@ import { BusyMessage, Thumbnail } from "component/common.js";
import FileList from "component/fileList";
import SubHeader from "component/subHeader";
class FileListPublished extends React.Component {
class FileListPublished extends React.PureComponent {
componentWillMount() {
this.props.fetchFileListPublished();
}

View file

@ -33,7 +33,7 @@ const FormatItem = props => {
);
};
class FilePage extends React.Component {
class FilePage extends React.PureComponent {
componentDidMount() {
this.fetchFileInfo(this.props);
this.fetchCostInfo(this.props);

View file

@ -5,7 +5,7 @@ import Link from "component/link";
import SubHeader from "component/subHeader";
import { BusyMessage } from "component/common";
class HelpPage extends React.Component {
class HelpPage extends React.PureComponent {
constructor(props) {
super(props);

View file

@ -6,7 +6,7 @@ import Link from "component/link";
import rewards from "rewards";
import Modal from "component/modal";
class PublishPage extends React.Component {
class PublishPage extends React.PureComponent {
constructor(props) {
super(props);

View file

@ -4,7 +4,7 @@ import { FormRow } from "component/form";
import Modal from "../component/modal.js";
import lbry from "../lbry.js";
class ReportPage extends React.Component {
class ReportPage extends React.PureComponent {
constructor(props) {
super(props);

View file

@ -4,7 +4,7 @@ import { CreditAmount, Icon } from "component/common.js";
import SubHeader from "component/subHeader";
import { RewardLink } from "component/reward-link";
export class RewardTile extends React.Component {
export class RewardTile extends React.PureComponent {
static propTypes = {
type: React.PropTypes.string.isRequired,
title: React.PropTypes.string.isRequired,
@ -34,7 +34,7 @@ export class RewardTile extends React.Component {
}
}
export class RewardsPage extends React.Component {
export class RewardsPage extends React.PureComponent {
constructor(props) {
super(props);

View file

@ -5,7 +5,7 @@ import FileListSearch from "component/fileListSearch";
import { ToolTip } from "component/tooltip.js";
import { BusyMessage } from "component/common.js";
class SearchPage extends React.Component {
class SearchPage extends React.PureComponent {
render() {
const { query } = this.props;

View file

@ -3,7 +3,7 @@ import { FormField, FormRow } from "component/form.js";
import SubHeader from "component/subHeader";
import lbry from "lbry.js";
class SettingsPage extends React.Component {
class SettingsPage extends React.PureComponent {
constructor(props) {
super(props);

View file

@ -4,7 +4,7 @@ import { BusyMessage } from "component/common";
import ChannelPage from "page/channel";
import FilePage from "page/filePage";
class ShowPage extends React.Component {
class ShowPage extends React.PureComponent {
componentWillMount() {
this.resolve(this.props);
}

View file

@ -1,7 +1,7 @@
import React from "react";
import lbry from "../lbry.js";
class StartPage extends React.Component {
class StartPage extends React.PureComponent {
componentWillMount() {
lbry.stop();
}