Skip to content

Instantly share code, notes, and snippets.

@cenkce
Last active February 21, 2019 12:29
Show Gist options
  • Save cenkce/665e8785d23e929d791e1898768310a5 to your computer and use it in GitHub Desktop.
Save cenkce/665e8785d23e929d791e1898768310a5 to your computer and use it in GitHub Desktop.
Instantly add component to context
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