Skip to content

Commit 900b206

Browse files
committed
Pass key through ReactComponentInfo to debug the Server Component's key
1 parent 49496d4 commit 900b206

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

packages/react-client/src/__tests__/ReactFlight-test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ describe('ReactFlight', () => {
299299
{
300300
name: 'Greeting',
301301
env: 'Server',
302+
key: null,
302303
owner: null,
303304
stack: gate(flag => flag.enableOwnerStacks)
304305
? ' in Object.<anonymous> (at **)'
@@ -337,6 +338,7 @@ describe('ReactFlight', () => {
337338
{
338339
name: 'Greeting',
339340
env: 'Server',
341+
key: null,
340342
owner: null,
341343
stack: gate(flag => flag.enableOwnerStacks)
342344
? ' in Object.<anonymous> (at **)'
@@ -2614,6 +2616,7 @@ describe('ReactFlight', () => {
26142616
{
26152617
name: 'ServerComponent',
26162618
env: 'Server',
2619+
key: null,
26172620
owner: null,
26182621
stack: gate(flag => flag.enableOwnerStacks)
26192622
? ' in Object.<anonymous> (at **)'
@@ -2631,6 +2634,7 @@ describe('ReactFlight', () => {
26312634
{
26322635
name: 'ThirdPartyComponent',
26332636
env: 'third-party',
2637+
key: null,
26342638
owner: null,
26352639
stack: gate(flag => flag.enableOwnerStacks)
26362640
? ' in Object.<anonymous> (at **)'
@@ -2645,6 +2649,7 @@ describe('ReactFlight', () => {
26452649
{
26462650
name: 'ThirdPartyLazyComponent',
26472651
env: 'third-party',
2652+
key: null,
26482653
owner: null,
26492654
stack: gate(flag => flag.enableOwnerStacks)
26502655
? ' in myLazy (at **)\n in lazyInitializer (at **)'
@@ -2659,6 +2664,7 @@ describe('ReactFlight', () => {
26592664
{
26602665
name: 'ThirdPartyFragmentComponent',
26612666
env: 'third-party',
2667+
key: '3',
26622668
owner: null,
26632669
stack: gate(flag => flag.enableOwnerStacks)
26642670
? ' in Object.<anonymous> (at **)'
@@ -2732,6 +2738,7 @@ describe('ReactFlight', () => {
27322738
{
27332739
name: 'ServerComponent',
27342740
env: 'Server',
2741+
key: null,
27352742
owner: null,
27362743
stack: gate(flag => flag.enableOwnerStacks)
27372744
? ' in Object.<anonymous> (at **)'
@@ -2748,6 +2755,7 @@ describe('ReactFlight', () => {
27482755
{
27492756
name: 'Keyed',
27502757
env: 'Server',
2758+
key: 'keyed',
27512759
owner: null,
27522760
stack: gate(flag => flag.enableOwnerStacks)
27532761
? ' in ServerComponent (at **)'
@@ -2763,6 +2771,7 @@ describe('ReactFlight', () => {
27632771
{
27642772
name: 'ThirdPartyAsyncIterableComponent',
27652773
env: 'third-party',
2774+
key: null,
27662775
owner: null,
27672776
stack: gate(flag => flag.enableOwnerStacks)
27682777
? ' in Object.<anonymous> (at **)'
@@ -2920,6 +2929,7 @@ describe('ReactFlight', () => {
29202929
{
29212930
name: 'Component',
29222931
env: 'A',
2932+
key: null,
29232933
owner: null,
29242934
stack: gate(flag => flag.enableOwnerStacks)
29252935
? ' in Object.<anonymous> (at **)'
@@ -3040,6 +3050,7 @@ describe('ReactFlight', () => {
30403050
const greetInfo = {
30413051
name: 'Greeting',
30423052
env: 'Server',
3053+
key: null,
30433054
owner: null,
30443055
stack: gate(flag => flag.enableOwnerStacks)
30453056
? ' in Object.<anonymous> (at **)'
@@ -3050,6 +3061,7 @@ describe('ReactFlight', () => {
30503061
{
30513062
name: 'Container',
30523063
env: 'Server',
3064+
key: null,
30533065
owner: greetInfo,
30543066
stack: gate(flag => flag.enableOwnerStacks)
30553067
? ' in Greeting (at **)'

packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMEdge-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ describe('ReactFlightDOMEdge', () => {
307307

308308
const serializedContent = await readResult(stream1);
309309

310-
expect(serializedContent.length).toBeLessThan(410);
310+
expect(serializedContent.length).toBeLessThan(425);
311311
expect(timesRendered).toBeLessThan(5);
312312

313313
const model = await ReactServerDOMClient.createFromReadableStream(stream2, {
@@ -374,7 +374,7 @@ describe('ReactFlightDOMEdge', () => {
374374
const [stream1, stream2] = passThrough(stream).tee();
375375

376376
const serializedContent = await readResult(stream1);
377-
expect(serializedContent.length).toBeLessThan(__DEV__ ? 590 : 400);
377+
expect(serializedContent.length).toBeLessThan(__DEV__ ? 605 : 400);
378378
expect(timesRendered).toBeLessThan(5);
379379

380380
const model = await ReactServerDOMClient.createFromReadableStream(stream2, {

packages/react-server/src/ReactFlightServer.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,7 @@ function callWithDebugContextInDEV<A, T>(
970970
const componentDebugInfo: ReactComponentInfo = {
971971
name: '',
972972
env: task.environmentName,
973+
key: null,
973974
owner: task.debugOwner,
974975
};
975976
if (enableOwnerStacks) {
@@ -1036,6 +1037,7 @@ function renderFunctionComponent<Props>(
10361037
componentDebugInfo = ({
10371038
name: componentName,
10381039
env: componentEnv,
1040+
key: key,
10391041
owner: task.debugOwner,
10401042
}: ReactComponentInfo);
10411043
if (enableOwnerStacks) {
@@ -1575,6 +1577,7 @@ function renderElement(
15751577
const componentDebugInfo: ReactComponentInfo = {
15761578
name: 'Fragment',
15771579
env: (0, request.environmentName)(),
1580+
key: key,
15781581
owner: task.debugOwner,
15791582
stack:
15801583
task.debugStack === null
@@ -2615,6 +2618,7 @@ function renderModelDestructive(
26152618
> = {
26162619
name: (value: any).name,
26172620
env: (value: any).env,
2621+
key: (value: any).key,
26182622
owner: (value: any).owner,
26192623
};
26202624
if (enableOwnerStacks) {
@@ -3287,6 +3291,7 @@ function renderConsoleValue(
32873291
> = {
32883292
name: (value: any).name,
32893293
env: (value: any).env,
3294+
key: (value: any).key,
32903295
owner: (value: any).owner,
32913296
};
32923297
if (enableOwnerStacks) {

packages/shared/ReactTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export type ReactStackTrace = Array<ReactCallSite>;
190190
export type ReactComponentInfo = {
191191
+name?: string,
192192
+env?: string,
193+
+key?: null | string,
193194
+owner?: null | ReactComponentInfo,
194195
+stack?: null | ReactStackTrace,
195196
// Stashed Data for the Specific Execution Environment. Not part of the transport protocol

0 commit comments

Comments
 (0)