Skip to content

Commit 7701069

Browse files
wjhsfjhefferman-sfdcnolanlawson
authored
fix(ssr): make context providers work again (#5004)
Co-authored-by: John Hefferman <jhefferman@salesforce.com> Co-authored-by: Nolan Lawson <nlawson@salesforce.com>
1 parent 6b40dc6 commit 7701069

File tree

38 files changed

+234
-14
lines changed

38 files changed

+234
-14
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<x-root>
2+
<x-provider>
3+
<!---->
4+
<x-consumer>
5+
<div>
6+
some context
7+
</div>
8+
</x-consumer>
9+
<!---->
10+
</x-provider>
11+
</x-root>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template lwc:render-mode="light">
2+
<div>{foo}</div>
3+
</template>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { LightningElement, wire } from 'lwc';
2+
import { WireAdapter } from '../../../wire-adapter';
3+
4+
export default class SlottedConsumerComponent extends LightningElement {
5+
static renderMode = 'light';
6+
@wire(WireAdapter) foo;
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template lwc:render-mode="light">
2+
<slot></slot>
3+
</template>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { LightningElement } from 'lwc';
2+
import { contextualizer } from '../../../wire-adapter';
3+
4+
export default class ProviderComponent extends LightningElement {
5+
static renderMode = 'light';
6+
connectedCallback() {
7+
contextualizer(this, {
8+
consumerConnectedCallback(consumer) {
9+
consumer.provide({
10+
value: 'some context',
11+
});
12+
},
13+
});
14+
}
15+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template lwc:render-mode="light">
2+
<x-provider>
3+
<x-consumer></x-consumer>
4+
</x-provider>
5+
</template>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { LightningElement } from 'lwc';
2+
3+
export default class Rootcomponent extends LightningElement {
4+
static renderMode = 'light';
5+
}

0 commit comments

Comments
 (0)