2193
</div>,
2194
);
2195
});
2196
- }).toErrorDev([
2197
- 'In HTML, <tr> cannot be a child of ' +
2198
- '<div>.\n' +
2199
- 'This will cause a hydration error.' +
2196
+ }).toErrorDev(
2197
+ 'In HTML, <tr> cannot be a child of <div>.\n' +
2198
+ 'This will cause a hydration error.\n' +
2199
+ '\n' +
2200
+ '> <div>\n' +
2201
+ '> <tr>\n' +
2202
+ ' ...\n' +
2203
'\n in tr (at **)' +
2201
- '\n in div (at **)',
2202
- ]);
2204
+ (gate(flags => flags.enableOwnerStacks)
2205
+ ? ''
2206
+ : '\n in div (at **)'),
2207
+ );
2208
});
2209
2210
it('warns on invalid nesting at root', async () => {
2220
);
2221
});
2222
}).toErrorDev(
2218
- 'In HTML, <p> cannot be a descendant ' +
2219
- 'of <p>.\n' +
2223
+ 'In HTML, <p> cannot be a descendant of <p>.\n' +
2224
'This will cause a hydration error.' +
2225
// There is no outer `p` here because root container is not part of the stack.
2226
'\n in p (at **)' +
2223
- '\n in span (at **)',
2227
+ (gate(flags => flags.enableOwnerStacks)
2228
+ ? ''
2229
+ : '\n in span (at **)'),
2230
);
2231
});
2232
2254
await act(() => {
2255
root.render(<Foo />);
2256
});
2251
- }).toErrorDev([
2252
- 'In HTML, <tr> cannot be a child of ' +
2253
- '<table>. Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated ' +
2254
- 'by the browser.\n' +
2255
- 'This will cause a hydration error.' +
2256
- '\n in tr (at **)' +
2257
- '\n in Row (at **)' +
2258
- '\n in table (at **)' +
2259
- '\n in Foo (at **)',
2260
- 'In HTML, text nodes cannot be a ' +
2261
- 'child of <tr>.\n' +
2262
- 'This will cause a hydration error.' +
2263
- '\n in tr (at **)' +
2264
- '\n in Row (at **)' +
2265
- '\n in table (at **)' +
2266
- '\n in Foo (at **)',
2267
- 'In HTML, whitespace text nodes cannot ' +
2268
- "be a child of <table>. Make sure you don't have any extra " +
2269
- 'whitespace between tags on each line of your source code.\n' +
2270
- 'This will cause a hydration error.' +
2271
- '\n in table (at **)' +
2272
- '\n in Foo (at **)',
2273
- ]);
2257
+ }).toErrorDev(
2258
+ gate(flags => flags.enableOwnerStacks)
2259
+ ? [
2260
+ 'In HTML, <tr> cannot be a child of ' +
2261
+ '<table>. Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated ' +
2262
+ 'by the browser.\n' +
2263
+ 'This will cause a hydration error.\n' +
2264
+ '\n' +
2265
+ ' <Foo>\n' +
2266
+ '> <table>\n' +
2267
+ ' <Row>\n' +
2268
+ '> <tr>\n' +
2269
+ ' ...\n' +
2270
+ '\n in tr (at **)' +
2271
+ '\n in Row (at **)',
2272
+ '<table> cannot contain a nested <tr>.\nSee this log for the ancestor stack trace.' +
2273
+ '\n in table (at **)' +
2274
+ '\n in Foo (at **)',
2275
+ 'In HTML, text nodes cannot be a ' +
2276
+ 'child of <tr>.\n' +
2277
+ 'This will cause a hydration error.\n' +
2278
+ '\n' +
2279
+ ' <Foo>\n' +
2280
+ ' <table>\n' +
2281
+ ' <Row>\n' +
2282
+ ' <tr>\n' +
2283
+ '> x\n' +
2284
+ ' ...\n' +
2285
+ '\n in tr (at **)' +
2286
+ '\n in Row (at **)',
2287
+ 'In HTML, whitespace text nodes cannot ' +
2288
+ "be a child of <table>. Make sure you don't have any extra " +
2289
+ 'whitespace between tags on each line of your source code.\n' +
2290
+ 'This will cause a hydration error.\n' +
2291
+ '\n' +
2292
+ ' <Foo>\n' +
2293
+ '> <table>\n' +
2294
+ ' <Row>\n' +
2295
+ '> {" "}\n' +
2296
+ '\n in table (at **)' +
2297
+ '\n in Foo (at **)',
2298
+ ]
2299
+ : [
2300
+ 'In HTML, <tr> cannot be a child of ' +
2301
+ '<table>. Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated ' +
2302
+ 'by the browser.\n' +
2303
+ 'This will cause a hydration error.\n' +
2304
+ '\n' +
2305
+ ' <Foo>\n' +
2306
+ '> <table>\n' +
2307
+ ' <Row>\n' +
2308
+ '> <tr>\n' +
2309
+ ' ...\n' +
2310
+ '\n in tr (at **)' +
2311
+ '\n in Row (at **)' +
2312
+ '\n in table (at **)' +
2313
+ '\n in Foo (at **)',
2314
+ 'In HTML, text nodes cannot be a ' +
2315
+ 'child of <tr>.\n' +
2316
+ 'This will cause a hydration error.\n' +
2317
+ '\n' +
2318
+ ' <Foo>\n' +
2319
+ ' <table>\n' +
2320
+ ' <Row>\n' +
2321
+ ' <tr>\n' +
2322
+ '> x\n' +
2323
+ ' ...\n' +
2324
+ '\n in tr (at **)' +
2325
+ '\n in Row (at **)' +
2326
+ '\n in table (at **)' +
2327
+ '\n in Foo (at **)',
2328
+ 'In HTML, whitespace text nodes cannot ' +
2329
+ "be a child of <table>. Make sure you don't have any extra " +
2330
+ 'whitespace between tags on each line of your source code.\n' +
2331
+ 'This will cause a hydration error.\n' +
2332
+ '\n' +
2333
+ ' <Foo>\n' +
2334
+ '> <table>\n' +
2335
+ ' <Row>\n' +
2336
+ '> {" "}\n' +
2337
+ '\n in table (at **)' +
2338
+ '\n in Foo (at **)',
2339
+ ],
2340
+ );
2341
});
2342
2343
it('warns nicely for updating table rows to use text', async () => {
2364
'In HTML, whitespace text nodes cannot ' +
2365
"be a child of <table>. Make sure you don't have any extra " +
2366
'whitespace between tags on each line of your source code.\n' +
2300
- 'This will cause a hydration error.' +
2367
+ 'This will cause a hydration error.\n' +
2368
+ '\n' +
2369
+ ' <Foo>\n' +
2370
+ ' <table>\n' +
2371
+ '> {" "}\n' +
2372
'\n in table (at **)' +
2373
'\n in Foo (at **)',
2374
]);
2396
}).toErrorDev([
2397
'In HTML, text nodes cannot be a ' +
2398
'child of <tr>.\n' +
2328
- 'This will cause a hydration error.' +
2399
+ 'This will cause a hydration error.\n' +
2400
+ '\n' +
2401
+ ' <Foo>\n' +
2402
+ ' <table>\n' +
2403
+ ' <tbody>\n' +
2404
+ ' <Row>\n' +
2405
+ ' <tr>\n' +
2406
+ '> text\n' +
2407
'\n in tr (at **)' +
2408
'\n in Row (at **)' +
2331
- '\n in tbody (at **)' +
2332
- '\n in table (at **)' +
2333
- '\n in Foo (at **)',
2409
+ (gate(flags => flags.enableOwnerStacks)
2410
+ ? ''
2411
+ : '\n in tbody (at **)' +
2412
+ '\n in table (at **)' +
2413
+ '\n in Foo (at **)'),
2414
]);
2415
});
2416
2439
root.render(<App1 />);
2440
});
2441
}).toErrorDev(
2362
- '\n in tr (at **)' +
2363
- '\n in Row (at **)' +
2364
- '\n in FancyRow (at **)' +
2365
- '\n in table (at **)' +
2366
- '\n in Viz1 (at **)',
2442
+ gate(flags => flags.enableOwnerStacks)
2443
+ ? [
2444
+ '\n in tr (at **)' +
2445
+ '\n in Row (at **)' +
2446
+ '\n in FancyRow (at **)' +
2447
+ '\n in Viz1 (at **)',
2448
+ '\n in table (at **)' + '\n in Viz1 (at **)',
2449
+ ]
2450
+ : [
2451
+ '\n in tr (at **)' +
2452
+ '\n in Row (at **)' +
2453
+ '\n in FancyRow (at **)' +
2454
+ '\n in table (at **)' +
2455
+ '\n in Viz1 (at **)',
2456
+ ],
2457
);
2458
});
2459
2495
root.render(<App2 />);
2496
});
2497
}).toErrorDev(
2408
- '\n in tr (at **)' +
2409
- '\n in Row (at **)' +
2410
- '\n in FancyRow (at **)' +
2411
- '\n in table (at **)' +
2412
- '\n in Table (at **)' +
2413
- '\n in FancyTable (at **)' +
2414
- '\n in Viz2 (at **)',
2498
+ gate(flags => flags.enableOwnerStacks)
2499
+ ? [
2500
+ '\n in tr (at **)' +
2501
+ '\n in Row (at **)' +
2502
+ '\n in FancyRow (at **)' +
2503
+ '\n in Viz2 (at **)',
2504
+ '\n in table (at **)' +
2505
+ '\n in Table (at **)' +
2506
+ '\n in FancyTable (at **)' +
2507
+ '\n in Viz2 (at **)',
2508
+ ]
2509
+ : [
2510
+ '\n in tr (at **)' +
2511
+ '\n in Row (at **)' +
2512
+ '\n in FancyRow (at **)' +
2513
+ '\n in table (at **)' +
2514
+ '\n in Table (at **)' +
2515
+ '\n in FancyTable (at **)' +
2516
+ '\n in Viz2 (at **)',
2517
+ ],
2518
);
2519
});
2520
2549
);
2550
});
2551
}).toErrorDev(
2449
- '\n in tr (at **)' +
2450
- '\n in Row (at **)' +
2451
- '\n in FancyRow (at **)' +
2452
- '\n in table (at **)' +
2453
- '\n in Table (at **)' +
2454
- '\n in FancyTable (at **)',
2552
+ gate(flags => flags.enableOwnerStacks)
2553
+ ? [
2554
+ '\n in tr (at **)' +
2555
+ '\n in Row (at **)' +
2556
+ '\n in FancyRow (at **)',
2557
+ '\n in table (at **)' +
2558
+ '\n in Table (at **)' +
2559
+ '\n in FancyTable (at **)',
2560
+ ]
2561
+ : [
2562
+ '\n in tr (at **)' +
2563
+ '\n in Row (at **)' +
2564
+ '\n in FancyRow (at **)' +
2565
+ '\n in table (at **)' +
2566
+ '\n in Table (at **)' +
2567
+ '\n in FancyTable (at **)',
2568
+ ],
2569
);
2570
});
2571
2589
);
2590
});
2591
}).toErrorDev(
2478
- '\n in tr (at **)' +
2479
- '\n in Row (at **)' +
2480
- '\n in FancyRow (at **)' +
2481
- '\n in table (at **)',
2592
+ gate(flags => flags.enableOwnerStacks)
2593
+ ? [
2594
+ '\n in tr (at **)' +
2595
+ '\n in Row (at **)' +
2596
+ '\n in FancyRow (at **)',
2597
+ '\n in table (at **)',
2598
+ ]
2599
+ : [
2600
+ '\n in tr (at **)' +
2601
+ '\n in Row (at **)' +
2602
+ '\n in FancyRow (at **)' +
2603
+ '\n in table (at **)',
2604
+ ],
2605
);
2606
});
2607
2629
);
2630
});
2631
}).toErrorDev(
2509
- '\n in tr (at **)' +
2510
- '\n in table (at **)' +
2511
- '\n in Table (at **)' +
2512
- '\n in FancyTable (at **)',
2632
+ gate(flags => flags.enableOwnerStacks)
2633
+ ? [
2634
+ '\n in tr (at **)',
2635
+ '\n in table (at **)' +
2636
+ '\n in Table (at **)' +
2637
+ '\n in FancyTable (at **)',
2638
+ ]
2639
+ : [
2640
+ '\n in tr (at **)' +
2641
+ '\n in table (at **)' +
2642
+ '\n in Table (at **)' +
2643
+ '\n in FancyTable (at **)',
2644
+ ],
2645
);
2646
2647
class Link extends React.Component {
2663
);
2664
});
2665
}).toErrorDev(
2534
- '\n in a (at **)' +
2535
- '\n in Link (at **)' +
2536
- '\n in div (at **)' +
2537
- '\n in a (at **)' +
2538
- '\n in Link (at **)',
2666
+ gate(flags => flags.enableOwnerStacks)
2667
+ ? [
2668
+ '\n in a (at **)' + '\n in Link (at **)',
2669
+ '\n in a (at **)' + '\n in Link (at **)',
2670
+ ]
2671
+ : [
2672
+ '\n in a (at **)' +
2673
+ '\n in Link (at **)' +
2674
+ '\n in div (at **)' +
2675
+ '\n in a (at **)' +
2676
+ '\n in Link (at **)',
2677
+ ],
2678
);
2679
});
2680