Skip to content

Instantly share code, notes, and snippets.

@pmdartus
Created October 4, 2022 08:09
Show Gist options
  • Save pmdartus/8e97ee2e5fdc04e0fd7f0f2772d409e5 to your computer and use it in GitHub Desktop.
Save pmdartus/8e97ee2e5fdc04e0fd7f0f2772d409e5 to your computer and use it in GitHub Desktop.
Example context consumer
import { LightningElement } from 'lwc';
import { I18nContextSymbol } from 'i18n/context';
// https://vuejs.org/guide/components/provide-inject.html#working-with-symbol-keys
export default class Foo extends LightningElement {
static context = {
[I18nContextSymbol]: { from: '18n' }
};
connectedCallback() {
console.log(this.i18n)
}
}
import { LightningElement } from 'lwc';
export default class Foo extends LightningElement {
static context = [
'i18n',
];
connectedCallback() {
console.log(this.i18n)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment