Skip to content

Commit

Permalink
Use PureComponent instead of Component (oblador#608)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunolemos authored and oblador committed Dec 19, 2017
1 parent 1c1e844 commit f6a1362
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Examples/IconExplorer/IconList.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import {
DeviceEventEmitter,
ListView,
Expand Down Expand Up @@ -46,7 +46,7 @@ const styles = StyleSheet.create({
},
});

export default class IconList extends Component {
export default class IconList extends PureComponent {
constructor(props) {
super(props);

Expand Down
4 changes: 2 additions & 2 deletions Examples/IconExplorer/IconSetList.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import {
Alert,
Image,
Expand Down Expand Up @@ -144,7 +144,7 @@ const styles = StyleSheet.create({
},
});

export default class IconSetsList extends Component {
export default class IconSetsList extends PureComponent {
constructor(props) {
super(props);

Expand Down
2 changes: 1 addition & 1 deletion Examples/IconExplorer/index.android.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import {
AppRegistry,
BackAndroid,
Expand Down
2 changes: 1 addition & 1 deletion Examples/IconExplorer/index.ios.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import {
AppRegistry,
NavigatorIOS,
Expand Down
6 changes: 3 additions & 3 deletions Examples/IconExplorer/index.osx.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import {
AppRegistry,
Dimensions,
Expand Down Expand Up @@ -37,7 +37,7 @@ const styles = StyleSheet.create({
},
});

class Welcome extends Component {
class Welcome extends PureComponent {
render() {
return (
<View style={styles.welcomeWrapper}>
Expand All @@ -47,7 +47,7 @@ class Welcome extends Component {
}
}

class IconExplorer extends Component {
class IconExplorer extends PureComponent {

constructor() {
super();
Expand Down
6 changes: 3 additions & 3 deletions Examples/IconExplorer/index.windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @flow
*/

import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import {
AppRegistry,
StyleSheet,
Expand Down Expand Up @@ -42,7 +42,7 @@ const styles = StyleSheet.create({
},
});

class Welcome extends Component {
class Welcome extends PureComponent {
render() {
return (
<View style={styles.welcomeWrapper}>
Expand All @@ -52,7 +52,7 @@ class Welcome extends Component {
}
}

class IconExplorer extends Component {
class IconExplorer extends PureComponent {

constructor() {
super();
Expand Down
6 changes: 3 additions & 3 deletions Examples/TabBarExample/index.ios.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import {
AppRegistry,
StyleSheet,
Expand Down Expand Up @@ -38,7 +38,7 @@ const styles = StyleSheet.create({
},
});

class ColoredView extends Component {
class ColoredView extends PureComponent {
componentWillMount() {
Icon.getImageSource('md-arrow-back', 30).then((source) => this.setState({ backIcon: source }));
}
Expand All @@ -65,7 +65,7 @@ class ColoredView extends Component {
}
}

class TabBarExample extends Component {
class TabBarExample extends PureComponent {
constructor(props) {
super(props);

Expand Down
4 changes: 2 additions & 2 deletions RNIMigration.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import FontAwesome from 'react-native-vector-icons/FontAwesome';
import Foundation from 'react-native-vector-icons/Foundation';
Expand All @@ -18,7 +18,7 @@ const ICON_SET_MAP = {

// This is a composition is a drop in replacement for users migrating from the
// react-native-icons module. Please don't use this component for new apps/views.
export default class Icon extends React.Component {
export default class Icon extends PureComponent {
static propTypes = {
name: PropTypes.string.isRequired,
size: PropTypes.number,
Expand Down
8 changes: 4 additions & 4 deletions directory/src/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import './App.css';
import Entypo from '../../glyphmaps/Entypo.json';
Expand Down Expand Up @@ -27,7 +27,7 @@ const IconFamilies = {
Zocial,
};

class Icon extends Component {
class Icon extends PureComponent {
static propTypes = {
family: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
Expand All @@ -54,7 +54,7 @@ const HeaderBar = (props) => {
);
};

class SearchBar extends Component {
class SearchBar extends PureComponent {
handleSubmit = (e) => {
e.preventDefault();
this.props.onSubmit(this.inputRef.value);
Expand All @@ -78,7 +78,7 @@ class SearchBar extends Component {
}
}

class App extends Component {
class App extends PureComponent {
constructor() {
super();
this.state = {
Expand Down
4 changes: 2 additions & 2 deletions lib/create-icon-set.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import {
NativeModules,
Expand Down Expand Up @@ -31,7 +31,7 @@ export default function createIconSet(glyphMap, fontFamily, fontFile) {

const IconNamePropType = PropTypes.oneOf(Object.keys(glyphMap));

class Icon extends Component {
class Icon extends PureComponent {
static propTypes = {
name: IconNamePropType,
size: PropTypes.number,
Expand Down
4 changes: 2 additions & 2 deletions lib/icon-button.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import isString from 'lodash/isString';
import omit from 'lodash/omit';
import pick from 'lodash/pick';
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { StyleSheet, Text, TouchableHighlight, View } from './react-native';

Expand All @@ -27,7 +27,7 @@ const styles = StyleSheet.create({
const IOS7_BLUE = '#007AFF';

export default function createIconButtonComponent(Icon) {
return class IconButton extends Component {
return class IconButton extends PureComponent {
static propTypes = {
backgroundColor: PropTypes.oneOfType([
PropTypes.string,
Expand Down
4 changes: 2 additions & 2 deletions lib/tab-bar-item-ios.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* eslint-disable react/no-unused-prop-types */
import isEqual from 'lodash/isEqual';
import pick from 'lodash/pick';
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { TabBarIOS } from './react-native';

export default function createTabBarItemIOSComponent(
IconNamePropType,
getImageSource
) {
return class TabBarItemIOS extends Component {
return class TabBarItemIOS extends PureComponent {
static propTypes = {
iconName: IconNamePropType.isRequired,
selectedIconName: IconNamePropType,
Expand Down
4 changes: 2 additions & 2 deletions lib/toolbar-android.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* eslint-disable react/no-unused-prop-types */
import isEqual from 'lodash/isEqual';
import pick from 'lodash/pick';
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { ToolbarAndroid } from './react-native';

export default function createToolbarAndroidComponent(
IconNamePropType,
getImageSource
) {
return class IconToolbarAndroid extends Component {
return class IconToolbarAndroid extends PureComponent {
static propTypes = {
logoName: IconNamePropType,
navIconName: IconNamePropType,
Expand Down

0 comments on commit f6a1362

Please sign in to comment.