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

perf: Use PureComponent to avoid useless re-renders (fixes #7248) #7258

Merged
merged 1 commit into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-router-dom/modules/BrowserRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import warning from "tiny-warning";
/**
* The public API for a <Router> that uses HTML5 history.
*/
class BrowserRouter extends React.Component {
class BrowserRouter extends React.PureComponent {
history = createHistory(this.props);

render() {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router-dom/modules/HashRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import warning from "tiny-warning";
/**
* The public API for a <Router> that uses window.location.hash.
*/
class HashRouter extends React.Component {
class HashRouter extends React.PureComponent {
history = createHistory(this.props);

render() {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router-native/BackButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BackHandler } from "react-native";

import { __RouterContext as RouterContext } from "react-router";

class BackButton extends React.Component {
class BackButton extends React.PureComponent {
handleBack = () => {
if (this.history.index === 0) {
return false; // home screen
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router-native/DeepLinking.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { __RouterContext as RouterContext } from "react-router";

const protocolAndSlashes = /.*?:\/\//g;

class DeepLinking extends React.Component {
class DeepLinking extends React.PureComponent {
push(url) {
const pathname = url.replace(protocolAndSlashes, "");
this.history.push(pathname);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router-native/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PropTypes from "prop-types";

import { __RouterContext as RouterContext } from "react-router";

export default class Link extends React.Component {
export default class Link extends React.PureComponent {
static defaultProps = {
component: TouchableHighlight,
replace: false
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router-native/experimental/StackRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const PARENT_TRAVEL_DISTANCE = 100;
const PARENT_FINAL_OPACITY = 0.25;
const CARD_SHADOW_RADIUS = 10;

class AnimatedStack extends React.Component {
class AnimatedStack extends React.PureComponent {
static propTypes = {
title: PropTypes.any,
content: PropTypes.any,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-router-native/experimental/TabRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { View } from "react-native";

import Link from "../Link.js";

export class TabRoutes extends React.Component {
export class TabRoutes extends React.PureComponent {
render() {
const { children } = this.props;
return (
Expand Down Expand Up @@ -36,7 +36,7 @@ export class TabRoutes extends React.Component {
}
}

export class TabRoute extends React.Component {
export class TabRoute extends React.PureComponent {
render() {
const { renderContent, path } = this.props;
return <Route path={path} render={renderContent} />;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router-native/index.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Prompt
} from "react-router-native";

class ReactRouterNative extends React.Component {
class ReactRouterNative extends React.PureComponent {
render() {
return (
<NativeRouter>
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/modules/Lifecycle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";

class Lifecycle extends React.Component {
class Lifecycle extends React.PureComponent {
componentDidMount() {
if (this.props.onMount) this.props.onMount.call(this, this);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/modules/MemoryRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Router from "./Router.js";
/**
* The public API for a <Router> that stores location in memory.
*/
class MemoryRouter extends React.Component {
class MemoryRouter extends React.PureComponent {
history = createHistory(this.props);

render() {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/modules/Route.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function evalChildrenDev(children, props, path) {
/**
* The public API for matching a single path and rendering.
*/
class Route extends React.Component {
class Route extends React.PureComponent {
render() {
return (
<RouterContext.Consumer>
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/modules/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import RouterContext from "./RouterContext.js";
/**
* The public API for putting history on context.
*/
class Router extends React.Component {
class Router extends React.PureComponent {
static computeRootMatch(pathname) {
return { path: "/", url: "/", params: {}, isExact: pathname === "/" };
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/modules/StaticRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function noop() {}
* location changes in a context object. Useful mainly in testing and
* server-rendering scenarios.
*/
class StaticRouter extends React.Component {
class StaticRouter extends React.PureComponent {
navigateTo(location, action) {
const { basename = "", context = {} } = this.props;
context.action = action;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/modules/Switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import matchPath from "./matchPath.js";
/**
* The public API for rendering the first <Route> that matches.
*/
class Switch extends React.Component {
class Switch extends React.PureComponent {
render() {
return (
<RouterContext.Consumer>
Expand Down