js styles replaced with css modules for performance

This commit is contained in:
NikolaBorislavovHristov 2018-06-04 17:40:04 +03:00
parent c55c0b7ba9
commit 63893f5690
3 changed files with 9 additions and 10 deletions

View file

@ -4,18 +4,19 @@ import styles from './styles';
class Checkbox extends Component {
shouldComponentUpdate(nextProps, nextState) {
return nextProps.checked !== this.props.checked;
return nextProps.checked !== this.props.checked ||
nextProps.enabled !== this.props.enabled;
}
onPress = () => {
if (typeof this.props.onPress === 'function') {
if (this.props.enabled && typeof this.props.onPress === 'function') {
this.props.onPress();
}
}
render() {
return (
<div style={styles.root} onClick={this.onPress} />
<div className={styles.root} onClick={this.onPress} />
);
}
}

View file

@ -0,0 +1,5 @@
.root {
width: 30px;
height: 30px;
background-color: red;
}

View file

@ -1,7 +0,0 @@
export default {
root: {
width: 300,
height: 300,
backgroundColor: 'red'
},
};