Created
November 9, 2014 19:46
-
-
Save aaronj1335/869a4f835b832ca7a41c to your computer and use it in GitHub Desktop.
This file contains 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
function Button() {} | |
Button.prototype = { | |
color: 'blue', | |
border: '1px solid black' | |
}; | |
// use classical inheritance or something like functional mixins to replicate | |
// the cascading nature of stylessheets | |
function ButtonActive() {} | |
ButtonActive.prototype = Object.create(Button.prototype); | |
ButtonActive.prototype.color = 'red'; | |
// now we may save some memory since `border` is only defined on | |
// Button.prototype | |
// | |
// also multiple react component instances can share `buttonStyle` and | |
// `buttonActiveStyle`, we don't need to instantiate a new style object every | |
// time. | |
var buttonStyle = new Button(); | |
var buttonActiveStyle = new ButtonActive(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment