How to use the react.PureComponent function in react

To help you get started, we’ve selected a few react examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uwrit / leaf / src / ui-login / src / components / LeftFooter.tsx View on Github external
/* Copyright (c) 2019, UW Medicine Research IT, University of Washington
 * Developed by Nic Dobbins and Cliff Spital, CRIO Sean Mooney
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */ 

import React from 'react';
import './Footer.css';

interface Props {}

export default class LeftFooter extends React.PureComponent {

    public render() {
        const c = 'footer';

        return (
            <div>
                <p>
                    <span>Developed with ❤️ in Seattle by </span> 
                    <a href="https://github.com/ndobb">Nic Dobbins</a>
                    <span> and </span>
                    <a href="https://github.com/cspital">Cliff Spital</a>
                    <span> of </span>
                    <a href="https://github.com/UW-Medicine-Research-IT">UW Medicine Research IT</a>
                </p>
            </div>
        );
github rizalibnu / commit-strip-react-native / src / components / Comic / index.js View on Github external
fontWeight: 'bold',
    fontSize: 24,
  },
  published: {
    marginTop: 15,
    fontSize: 12,
    color: Colors.grey600,
  },
  buttonWrapper: {
    position: 'absolute',
    bottom: 0,
  },
});

/* eslint camelcase: 0 */
class Comic extends React.PureComponent {
  constructor() {
    super();

    this.state = {
      loading: true,
      pageWidth: width,
    };
  }

  getNewDimensions = (event) =&gt; {
    this.setState({
      pageWidth: event.nativeEvent.layout.width,
    });
  }

  /* eslint class-methods-use-this: 0 */
github iotaledger / trinity-wallet / src / desktop / src / ui / views / settings / Language.js View on Github external
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { I18N_LOCALE_LABELS, I18N_LOCALES } from 'libs/i18n';
import { withI18n } from 'react-i18next';
import Select from 'ui/components/input/Select';
import i18next from 'libs/i18next';
import { setLocale } from 'actions/settings';

import Button from 'ui/components/Button';

/**
 * Interface locale selection component
 */
class LanguageSelect extends React.PureComponent {
    static propTypes = {
        /** @ignore */
        locale: PropTypes.string,
        /** @ignore */
        setLocale: PropTypes.func.isRequired,
        /** @ignore */
        t: PropTypes.func.isRequired,
    };

    state = {
        selection: null,
    };

    changeLocale = (e) => {
        e.preventDefault();
github mozilla / normandy / client / control / components / forms / FormActions.js View on Github external
/**
 * Container for buttons displayed at the bottom of a form.
 *
 * Example:
 *
 * 
 *   
 *     <button>Save</button>
 *   
 *   
 *     <button>Delete</button>
 *   
 * 
 */
export default class FormActions extends React.PureComponent {
  /**
   * Container for the primary actions (floated to the right).
   */
  static Primary = class Primary extends React.PureComponent {
    static propTypes = {
      children: PropTypes.node,
    };

    static defaultProps = {
      children: null,
    };

    render() {
      const { children } = this.props;
      return <div>{children}</div>;
    }
github sourcegraph / browser-extensions / app / components / CXPCommands.tsx View on Github external
private onAnchorClick: React.MouseEventHandler = e =&gt; {
        if (this.props.onSelect) {
            this.props.onSelect()
        }
    }

    private onAnchorKeyPress: React.KeyboardEventHandler = e =&gt; {
        if (isSelectKeyPress(e)) {
            if (this.props.onSelect) {
                this.props.onSelect()
            }
        }
    }
}

export class ContributedActionItem extends React.PureComponent {
    public state: State = { actionOrError: null }

    private commandExecutions = new Subject()
    private subscriptions = new Subscription()

    public componentDidMount(): void {
        this.subscriptions.add(
            this.commandExecutions
                .pipe(
                    mergeMap(params =&gt;
                        from(this.props.cxpController.registries.commands.executeCommand(params)).pipe(
                            mapTo(null),
                            catchError(error =&gt; [asError(error)]),
                            map(c =&gt; ({ actionOrError: c })),
                            startWith&gt;({ actionOrError: LOADING })
                        )
github mojisrc / fashop-admin / src / layouts / userLayout.js View on Github external
import Link from "umi/link";
import { Icon } from "antd";
import GlobalFooter from "@/components/globalFooter";
import styles from "./userLayout.less";
import logo from "@/assets/images/loginLogo.png";

const links = [
];

const copyright = (
    
        Copyright  FaShop 商城系统 - Power By FaShop ( www.fashop.cn )
    
);

class UserLayout extends React.PureComponent {

    render() {
        const { children } = this.props;
        return (
            <div>
                <div>
                    <div>
                        <div>
                            
                                <img src="{logo}" alt="logo">
                            
                        </div>
                    </div>
                    {children}
                </div>
                </div>
github mixer / webpack-bundle-compare / src / client / components / bundlephobia-stats.component.tsx View on Github external
import { Errors } from './errors.component';
import { SideEffectHint, TreeShakeHint } from './hints/hints.component';
import { BasePanel } from './panels/base-panel.component';
import { BooleanPanel } from './panels/boolean-panel.component';
import { CounterPanel } from './panels/counter-panel.component';
import { Placeholder } from './placeholder.component';
import { IndefiniteProgressBar } from './progress-bar.component';
import { color } from './util';

interface IProps {
  name: string;
  stats: Retrieval;
  retrieve(name: string): void;
}

class BundlephobiaStatsComponent extends React.PureComponent {
  public componentDidMount() {
    if (shouldAttempt(this.props.stats)) {
      this.props.retrieve(this.props.name);
    }
  }
  public componentDidUpdate(prevProps: IProps) {
    if (this.props.name !== prevProps.name &amp;&amp; shouldAttempt(this.props.stats)) {
      this.props.retrieve(this.props.name);
    }
  }

  public render() {
    const stats = this.props.stats;

    switch (stats.state) {
      case RetrievalState.Errored:
github SonarSource / sonarqube / server / sonar-web / src / main / js / apps / webhooks / components / DeliveryAccordion.tsx View on Github external
import AlertSuccessIcon from 'sonar-ui-common/components/icons/AlertSuccessIcon';
import { getDelivery } from '../../../api/webhooks';
import DateTimeFormatter from '../../../components/intl/DateTimeFormatter';
import DeliveryItem from './DeliveryItem';

interface Props {
  delivery: T.WebhookDelivery;
}

interface State {
  loading: boolean;
  open: boolean;
  payload?: string;
}

export default class DeliveryAccordion extends React.PureComponent {
  mounted = false;
  state: State = { loading: false, open: false };

  componentDidMount() {
    this.mounted = true;
  }

  componentWillUnmount() {
    this.mounted = false;
  }

  fetchPayload = ({ delivery } = this.props) =&gt; {
    this.setState({ loading: true });
    return getDelivery({ deliveryId: delivery.id }).then(
      ({ delivery }) =&gt; {
        if (this.mounted) {
github SonarSource / sonarqube / server / sonar-web / src / main / js / apps / projectActivity / components / forms / RemoveAnalysisForm.js View on Github external
/*::
type Props = {
  analysis: Analysis,
  deleteAnalysis: (analysis: string) =&gt; Promise&lt;*&gt;,
  onClose: () =&gt; void;
};
*/

/*::
type State = {
  processing: boolean
};
*/

export default class RemoveAnalysisForm extends React.PureComponent {
  /*:: mounted: boolean; */
  /*:: props: Props; */
  state /*: State */ = {
    processing: false
  };

  componentDidMount() {
    this.mounted = true;
  }

  componentWillUnmount() {
    this.mounted = false;
  }

  stopProcessing = () =&gt; {
    if (this.mounted) {
github mozilla / delivery-console / src / components / forms / IdenticonField.js View on Github external
import { Button, Popover, Icon } from 'antd';
import { fromJS, List } from 'immutable';
import autobind from 'autobind-decorator';
import React from 'react';
import PropTypes from 'prop-types';

import ShieldIdenticon from 'console/components/common/ShieldIdenticon';

@autobind
class IdenticonField extends React.PureComponent {
  static propTypes = {
    disabled: PropTypes.bool,
    onChange: PropTypes.func,
    value: PropTypes.any,
  };

  static defaultProps = {
    disabled: false,
  };

  static generateSeed() {
    return `v1:${Math.random()
      .toString(36)
      .substr(2)}`;
  }