Last active
August 17, 2016 13:39
-
-
Save conor909/3bcc763793252062e643c3fc8a27652f to your computer and use it in GitHub Desktop.
declarative versus imperative
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const minWidth = 220; | |
const minColumns = 1; | |
const maxColumns = 5; | |
const numberOfColumns = clamp( | |
this.props.containerWidth / minWidth, | |
minColumns, | |
maxColumns); | |
// vs | |
const { containerWidth } = this.props; | |
let numberOfColumns; | |
switch(true) { | |
default: | |
numberOfColumns = 5; | |
break; | |
case containerWidth < 640: | |
numberOfColumns = 1; | |
break; | |
case containerWidth < 800: | |
numberOfColumns = 2; | |
break; | |
case containerWidth < 900: | |
numberOfColumns = 3; | |
break; | |
case containerWidth < 1050: | |
numberOfColumns = 4; | |
break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment