Created
October 4, 2022 08:09
-
-
Save pmdartus/8e97ee2e5fdc04e0fd7f0f2772d409e5 to your computer and use it in GitHub Desktop.
Example context consumer
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
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) | |
} | |
} |
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
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