Last active
February 21, 2019 12:29
-
-
Save cenkce/665e8785d23e929d791e1898768310a5 to your computer and use it in GitHub Desktop.
Instantly add component to context
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
class StylingComponent { | |
} | |
StylingComponent.$$styleContext = { | |
classNames: "", | |
userProps: { | |
width: null, | |
height: null, | |
paddingLeft: 10, | |
paddingRight: 10 | |
} | |
}; | |
const Page1 = extends(Page)(function Page1(_super) { | |
_super(this); | |
const stylingComponent = new StylingComponent(); | |
stylingComponent.subscribeContext({ | |
type, // context type | |
style, // style with native objects | |
rawStyle // style with json objects | |
}) { | |
// can update any component here when theme is changed | |
console.log('styling context'); | |
console.log(JSON.stringify(rawStyle)); | |
} | |
this._children['instantComponent'] = stylingComponent; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment