From 63893f5690ba4b5848a79f7d578359e91fe0cee8 Mon Sep 17 00:00:00 2001 From: NikolaBorislavovHristov Date: Mon, 4 Jun 2018 17:40:04 +0300 Subject: [PATCH] js styles replaced with css modules for performance --- src/common/checkbox/checkbox.js | 7 ++++--- src/common/checkbox/styles.css | 5 +++++ src/common/checkbox/styles.js | 7 ------- 3 files changed, 9 insertions(+), 10 deletions(-) create mode 100644 src/common/checkbox/styles.css delete mode 100644 src/common/checkbox/styles.js diff --git a/src/common/checkbox/checkbox.js b/src/common/checkbox/checkbox.js index 2954da79b..707c30d6c 100644 --- a/src/common/checkbox/checkbox.js +++ b/src/common/checkbox/checkbox.js @@ -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 ( -
+
); } } diff --git a/src/common/checkbox/styles.css b/src/common/checkbox/styles.css new file mode 100644 index 000000000..734836d2e --- /dev/null +++ b/src/common/checkbox/styles.css @@ -0,0 +1,5 @@ +.root { + width: 30px; + height: 30px; + background-color: red; +} diff --git a/src/common/checkbox/styles.js b/src/common/checkbox/styles.js deleted file mode 100644 index 953e15580..000000000 --- a/src/common/checkbox/styles.js +++ /dev/null @@ -1,7 +0,0 @@ -export default { - root: { - width: 300, - height: 300, - backgroundColor: 'red' - }, -};