Skip to content

Commit

Permalink
Declare components as pure.
Browse files Browse the repository at this point in the history
related to #48
  • Loading branch information
ivgraai committed Jun 26, 2020
1 parent f51a2bd commit 82bcb66
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion components/GoodList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import CachedImage from "../components/CachedImage";
import DbHelper from "../services/DbHelper";
import { styles } from "../constants/styles/GoodList";

class GoodList extends React.PureComponent {
class GoodList extends React.Component {
static contextType = ThemeContext;
render() {
const theme = this.context;
Expand Down
4 changes: 2 additions & 2 deletions components/StyledButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import React from "react";
import { TouchableOpacity, Text, View } from "react-native";
import { styles } from "../constants/styles/StyledButton";

export default function StyledButton(props: any) {
export default React.memo(function StyledButton(props: any) {
return <View style={props.style}>
<TouchableOpacity style={[styles.touchableOpacity, !props.inverted ? styles.touchableOpacityColors : styles.invertedTouchableOpacityColors]} onPress={props.onPress} testID={props.testID} disabled={props.disabled}>
<Text style={[styles.text, !props.inverted ? styles.textColors : styles.invertedTextColors]}>
{props.children}
</Text>
</TouchableOpacity>
</View>;
}
})
4 changes: 2 additions & 2 deletions components/StyledTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import React from "react";
import { View, Text, TextInput } from "react-native";
import { styles } from "../constants/styles/StyledTextInput";

export default function StyledTextInput(props: any) {
export default React.memo(function StyledTextInput(props: any) {
return <View style={styles.view}>
<View style={styles.textView}>
<Text style={styles.text}>{props.header}</Text>
</View>
<TextInput {...props} />
</View>;
}
})
4 changes: 2 additions & 2 deletions components/TabBarLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { Text, PixelRatio } from 'react-native';

import Colors from '../constants/Colors';

export default function TabBarLabel(props: any) {
export default React.memo(function TabBarLabel(props: any) {
return <Text style={{
fontWeight: props.focused ? 'bold' : 'normal',
color: Colors.tintColor,
fontSize: (!props.focused ? 13 : 15) * PixelRatio.getFontScale()
}}>
{props.children}
</Text>;
}
})

0 comments on commit 82bcb66

Please sign in to comment.