Skip to content

Commit e36b38c

Browse files
authored
[Fiber] Fix some of the warnings (#8570)
* Implement component stack for some warnings in Fiber * Keep Fiber debug source up to date When an element changes, we should copy the source and owner again. Otherwise they can get stale since we're not reading them from the element. * Remove outdated TODOs from tests * Explicitly specify Fiber types to include in the stack Fixes an accidental omission when both source and owner are null but displayName exists. * Fix mised Stack+Fiber test to not expect extra warnings When we're in Fiber mode we don't actually expect that warning being printed. * Warn on passing different props to super() * Implement duplicate key warnings We keep known keys in a set in development. There is an annoying special case where we know we'll check it again because we break out of the loop early. One test in the tree hook regresses to the failing state because it checks that the tree hook works without a Set available, but we started using Set in this code. It is not essential and we can clean this up later when we decide how to deal with polyfills. * Move ReactTypeOfWork to src/shared It needs to be available both to Fiber and Isomorphic because the tree hook lives in Isomorphic but pretty-prints Fiber stack. * Add dev-only ReactDebugCurrentFiber for warnings The goal is to use ReactCurrentOwner less and rely on ReactDebugCurrentFiber for warning owner name and stack. * Make Stack invariant messages more consistent Fiber used a helper so two tests had the same phrasing. Stack also used a helper for most invariants but hardcoded a different phrase in one place. I changed that invariant message to use a helper which made it consistent with what it prints in Fiber. * Make CSSPropertyOperations use getCurrentFiberOwnerName() This gets mount-time CSS warnings to be printed. However update-time warnings are currently ignored because current fiber is not yet available during the commit phase. We also regress on HostOperation hook tests but this doesn't matter because it's only used by ReactPerf and it doesn't work with Fiber yet anyway. We'll have to think more about it later. * Set ReactDebugCurrentFiber during the commit phase This makes it available during updates, fixing the last failing test in CSSPropertyOperations. * Add DOM warnings by calling hooks directly It is not clear if the old hook system is worth it in its generic incarnation. For now I am just hooking it up to the DOMFiber renderer directly. * Add client-side counterparts for some warning tests This helps us track which warnings are really failing in Fiber, and which ones depend on SSR.
1 parent ab72f62 commit e36b38c

31 files changed

+870
-249
lines changed

scripts/fiber/tests-failing.txt

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ src/isomorphic/classic/__tests__/ReactContextValidator-test.js
1212
src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js
1313
* includes the owner name when passing null, undefined, boolean, or number
1414

15-
src/isomorphic/modern/element/__tests__/ReactJSXElementValidator-test.js
16-
* should give context for PropType errors in nested components.
17-
1815
src/renderers/dom/__tests__/ReactDOMProduction-test.js
1916
* should throw with an error code in production
2017

@@ -23,14 +20,11 @@ src/renderers/dom/shared/__tests__/ReactDOM-test.js
2320
* throws in render() if the update callback is not a function
2421

2522
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
26-
* should warn for children on void elements
27-
* should report component containing invalid styles
2823
* should clean up input value tracking
2924
* should clean up input textarea tracking
30-
* gives source code refs for unknown prop warning
31-
* gives source code refs for unknown prop warning for update render
32-
* gives source code refs for unknown prop warning for exact elements
33-
* gives source code refs for unknown prop warning for exact elements in composition
25+
* gives source code refs for unknown prop warning (ssr)
26+
* gives source code refs for unknown prop warning for exact elements (ssr)
27+
* gives source code refs for unknown prop warning for exact elements in composition (ssr)
3428

3529
src/renderers/dom/shared/__tests__/ReactDOMTextComponent-test.js
3630
* can reconcile text merged by Node.normalize() alongside other elements
@@ -64,7 +58,6 @@ src/renderers/shared/__tests__/ReactPerf-test.js
6458
* should work when measurement starts during reconciliation
6559

6660
src/renderers/shared/hooks/__tests__/ReactComponentTreeHook-test.js
67-
* gets created
6861
* can be retrieved by ID
6962

7063
src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js

scripts/fiber/tests-passing-except-dev.txt

Lines changed: 2 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,16 @@
11
src/addons/transitions/__tests__/ReactTransitionGroup-test.js
22
* should warn for duplicated keys with component stack info
33

4-
src/isomorphic/classic/__tests__/ReactContextValidator-test.js
5-
* should check context types
6-
* should check child context types
7-
8-
src/isomorphic/classic/element/__tests__/ReactElementClone-test.js
9-
* should check declared prop types after clone
10-
11-
src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js
12-
* warns for keys for arrays of elements with owner info
13-
* warns for keys with component stack info
14-
* should give context for PropType errors in nested components.
15-
16-
src/isomorphic/modern/element/__tests__/ReactJSXElementValidator-test.js
17-
* warns for keys for arrays of elements with owner info
18-
19-
src/renderers/dom/shared/__tests__/CSSPropertyOperations-test.js
20-
* should warn when using hyphenated style names
21-
* should warn when updating hyphenated style names
22-
* warns when miscapitalizing vendored style names
23-
* should warn about style having a trailing semicolon
24-
* should warn about style containing a NaN value
25-
264
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
27-
* should warn for unknown prop
28-
* should group multiple unknown prop warnings together
29-
* should warn for onDblClick prop
30-
* should emit a warning once for a named custom component using shady DOM
315
* should not warn when server-side rendering `onScroll`
326
* warns on invalid nesting
337
* warns on invalid nesting at root
348
* warns nicely for table rows
359
* gives useful context in warnings
3610
* should warn about incorrect casing on properties (ssr)
3711
* should warn about incorrect casing on event handlers (ssr)
38-
* should warn about incorrect casing on properties
39-
* should warn about incorrect casing on event handlers
40-
* should warn about class
41-
* should suggest property name if available
42-
43-
src/renderers/dom/shared/__tests__/ReactDOMInvalidARIAHook-test.js
44-
* should warn for one invalid aria-* prop
45-
* should warn for many invalid aria-* props
46-
* should warn for an improperly cased aria-* prop
12+
* should warn about class (ssr)
13+
* should suggest property name if available (ssr)
4714

4815
src/renderers/dom/shared/__tests__/ReactMount-test.js
4916
* should warn if mounting into dirty rendered markup
@@ -59,17 +26,6 @@ src/renderers/dom/shared/__tests__/ReactMountDestruction-test.js
5926
src/renderers/dom/shared/__tests__/ReactServerRendering-test.js
6027
* should have the correct mounting behavior
6128

62-
src/renderers/dom/shared/wrappers/__tests__/ReactDOMInput-test.js
63-
* should warn if value is null
64-
* should warn if controlled input switches to uncontrolled (value is null)
65-
* should warn if uncontrolled input (value is null) switches to controlled
66-
67-
src/renderers/dom/shared/wrappers/__tests__/ReactDOMSelect-test.js
68-
* should warn if value is null
69-
70-
src/renderers/dom/shared/wrappers/__tests__/ReactDOMTextarea-test.js
71-
* should warn if value is null
72-
7329
src/renderers/shared/hooks/__tests__/ReactComponentTreeHook-test.js
7430
* uses displayName or Unknown for classic components
7531
* uses displayName, name, or ReactComponent for modern components
@@ -136,12 +92,8 @@ src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js
13692
* gets recorded during an update
13793
* gets ignored if the styles are shallowly equal
13894
* gets recorded during mount
139-
* gets recorded during an update
140-
* gets recorded as a removal during an update
14195
* gets recorded during mount
142-
* gets recorded during an update
14396
* gets recorded during mount
144-
* gets recorded during an update
14597
* gets recorded during an update from text content
14698
* gets recorded during an update from html
14799
* gets recorded during an update from children
@@ -154,10 +106,6 @@ src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js
154106
* gets reported when a child is inserted
155107
* gets reported when a child is removed
156108

157-
src/renderers/shared/shared/__tests__/ReactChildReconciler-test.js
158-
* warns for duplicated keys
159-
* warns for duplicated keys with component stack info
160-
161109
src/renderers/shared/shared/__tests__/ReactComponentLifeCycle-test.js
162110
* should correctly determine if a component is mounted
163111
* should correctly determine if a null component is mounted
@@ -167,17 +115,10 @@ src/renderers/shared/shared/__tests__/ReactCompositeComponent-test.js
167115
* should warn about `forceUpdate` on unmounted components
168116
* should warn about `setState` on unmounted components
169117
* should disallow nested render calls
170-
* should warn when mutated props are passed
171118

172119
src/renderers/shared/shared/__tests__/ReactMultiChild-test.js
173-
* should warn for duplicated keys with component stack info
174120
* should warn for using maps as children with owner info
175121

176122
src/renderers/shared/shared/__tests__/ReactStatelessComponent-test.js
177123
* should warn for childContextTypes on a functional component
178124
* should warn when given a ref
179-
* should use correct name in key warning
180-
181-
src/renderers/shared/shared/__tests__/refs-test.js
182-
* attaches, detaches from fiber component with stack layer
183-
* attaches, detaches from stack component with fiber layer

scripts/fiber/tests-passing.txt

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ src/isomorphic/children/__tests__/sliceChildren-test.js
153153
src/isomorphic/classic/__tests__/ReactContextValidator-test.js
154154
* should filter out context not in contextTypes
155155
* should pass next context to lifecycles
156+
* should check context types
157+
* should check child context types
156158

157159
src/isomorphic/classic/class/__tests__/ReactBind-test.js
158160
* Holds reference to instance
@@ -266,20 +268,24 @@ src/isomorphic/classic/element/__tests__/ReactElementClone-test.js
266268
* does not warns for arrays of elements with keys
267269
* does not warn when the element is directly in rest args
268270
* does not warn when the array contains a non-element
271+
* should check declared prop types after clone
269272
* should ignore key and ref warning getters
270273
* should ignore undefined key and ref
271274
* should extract null key and ref
272275

273276
src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js
274277
* warns for keys for arrays of elements in rest args
278+
* warns for keys for arrays of elements with owner info
275279
* warns for keys for arrays with no owner or parent info
276280
* warns for keys for arrays of elements with no owner info
281+
* warns for keys with component stack info
277282
* does not warn for keys when passing children down
278283
* warns for keys for iterables of elements in rest args
279284
* does not warns for arrays of elements with keys
280285
* does not warns for iterable elements with keys
281286
* does not warn when the element is directly in rest args
282287
* does not warn when the array contains a non-element
288+
* should give context for PropType errors in nested components.
283289
* gives a helpful error when passing null, undefined, boolean, or number
284290
* should check default prop values
285291
* should not check the default for explicit null
@@ -471,12 +477,15 @@ src/isomorphic/modern/element/__tests__/ReactJSXElement-test.js
471477

472478
src/isomorphic/modern/element/__tests__/ReactJSXElementValidator-test.js
473479
* warns for keys for arrays of elements in children position
480+
* warns for keys for arrays of elements with owner info
474481
* warns for keys for iterables of elements in rest args
475482
* does not warns for arrays of elements with keys
476483
* does not warns for iterable elements with keys
477484
* does not warn for numeric keys in entry iterable as a child
478485
* does not warn when the element is directly as children
479486
* does not warn when the child array contains non-elements
487+
* should give context for PropType errors in nested components.
488+
* should update component stack after receiving next element
480489
* gives a helpful error when passing null, undefined, or boolean
481490
* should check default prop values
482491
* should not check the default for explicit null
@@ -543,6 +552,11 @@ src/renderers/dom/shared/__tests__/CSSPropertyOperations-test.js
543552
* should create vendor-prefixed markup correctly
544553
* should set style attribute when styles exist
545554
* should not set style attribute when no styles exist
555+
* should warn when using hyphenated style names
556+
* should warn when updating hyphenated style names
557+
* warns when miscapitalizing vendored style names
558+
* should warn about style having a trailing semicolon
559+
* should warn about style containing a NaN value
546560

547561
src/renderers/dom/shared/__tests__/DOMPropertyOperations-test.js
548562
* should create markup for simple properties
@@ -607,6 +621,9 @@ src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
607621
* should gracefully handle various style value types
608622
* should not update styles when mutating a proxy style object
609623
* should throw when mutating style objectsd
624+
* should warn for unknown prop
625+
* should group multiple unknown prop warnings together
626+
* should warn for onDblClick prop
610627
* should not warn for "0" as a unitless style value
611628
* should warn nicely about NaN in style
612629
* should update styles if initially null
@@ -644,6 +661,8 @@ src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
644661
* should warn on upper case HTML tags, not SVG nor custom tags
645662
* should warn against children for void elements
646663
* should warn against dangerouslySetInnerHTML for void elements
664+
* should include owner rather than parent in warnings
665+
* should emit a warning once for a named custom component using shady DOM
647666
* should emit a warning once for an unnamed custom component using shady DOM
648667
* should treat menuitem as a void element but still create the closing tag
649668
* should validate against multiple children props
@@ -656,20 +675,31 @@ src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
656675
* should validate against invalid styles
657676
* should track input values
658677
* should track textarea values
678+
* should warn for children on void elements
659679
* should support custom elements which extend native elements
660680
* should warn against children for void elements
661681
* should warn against dangerouslySetInnerHTML for void elements
662682
* should validate against multiple children props
663683
* should warn about contentEditable and children
664684
* should validate against invalid styles
685+
* should report component containing invalid styles
665686
* should properly escape text content and attributes values
666687
* unmounts children before unsetting DOM node info
667688
* should warn about the `onScroll` issue when unsupported (IE8)
668689
* should throw when an invalid tag name is used server-side
669690
* should throw when an attack vector is used server-side
670691
* should throw when an invalid tag name is used
671692
* should throw when an attack vector is used
693+
* should warn about incorrect casing on properties
694+
* should warn about incorrect casing on event handlers
695+
* should warn about class
672696
* should warn about props that are no longer supported
697+
* should warn about props that are no longer supported (ssr)
698+
* gives source code refs for unknown prop warning
699+
* gives source code refs for unknown prop warning for update render
700+
* gives source code refs for unknown prop warning for exact elements
701+
* gives source code refs for unknown prop warning for exact elements in composition
702+
* should suggest property name if available
673703

674704
src/renderers/dom/shared/__tests__/ReactDOMComponentTree-test.js
675705
* finds nodes for instances
@@ -680,6 +710,9 @@ src/renderers/dom/shared/__tests__/ReactDOMIDOperations-test.js
680710

681711
src/renderers/dom/shared/__tests__/ReactDOMInvalidARIAHook-test.js
682712
* should allow valid aria-* props
713+
* should warn for one invalid aria-* prop
714+
* should warn for many invalid aria-* props
715+
* should warn for an improperly cased aria-* prop
683716

684717
src/renderers/dom/shared/__tests__/ReactDOMSVG-test.js
685718
* creates initial namespaced markup
@@ -933,11 +966,14 @@ src/renderers/dom/shared/wrappers/__tests__/ReactDOMInput-test.js
933966
* should have a this value of undefined if bind is not used
934967
* should warn with checked and no onChange handler with readOnly specified
935968
* should update defaultValue to empty string
969+
* should warn if value is null
936970
* should warn if checked and defaultChecked props are specified
937971
* should warn if value and defaultValue props are specified
938972
* should warn if controlled input switches to uncontrolled (value is undefined)
973+
* should warn if controlled input switches to uncontrolled (value is null)
939974
* should warn if controlled input switches to uncontrolled with defaultValue
940975
* should warn if uncontrolled input (value is undefined) switches to controlled
976+
* should warn if uncontrolled input (value is null) switches to controlled
941977
* should warn if controlled checkbox switches to uncontrolled (checked is undefined)
942978
* should warn if controlled checkbox switches to uncontrolled (checked is null)
943979
* should warn if controlled checkbox switches to uncontrolled with defaultChecked
@@ -983,6 +1019,7 @@ src/renderers/dom/shared/wrappers/__tests__/ReactDOMSelect-test.js
9831019
* should support server-side rendering with defaultValue
9841020
* should support server-side rendering with multiple
9851021
* should not control defaultValue if readding options
1022+
* should warn if value is null
9861023
* should refresh state on change
9871024
* should warn if value and defaultValue props are specified
9881025
* should be able to safely remove select onChange
@@ -1015,6 +1052,7 @@ src/renderers/dom/shared/wrappers/__tests__/ReactDOMTextarea-test.js
10151052
* should allow objects as children
10161053
* should throw with multiple or invalid children
10171054
* should unmount
1055+
* should warn if value is null
10181056
* should warn if value and defaultValue are specified
10191057

10201058
src/renderers/native/__tests__/ReactNativeAttributePayload-test.js
@@ -1204,6 +1242,7 @@ src/renderers/shared/fiber/__tests__/ReactTopLevelText-test.js
12041242
* should render a component returning numbers directly from render
12051243

12061244
src/renderers/shared/hooks/__tests__/ReactComponentTreeHook-test.js
1245+
* gets created
12071246
* is created during mounting
12081247
* is created when calling renderToString during render
12091248

@@ -1258,11 +1297,21 @@ src/renderers/shared/hooks/__tests__/ReactComponentTreeHook-test.native.js
12581297

12591298
src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js
12601299
* gets ignored for composite roots that return null
1300+
* gets recorded during an update
1301+
* gets recorded as a removal during an update
1302+
* gets recorded during an update
1303+
* gets recorded during an update
12611304
* gets ignored if new text is equal
12621305
* gets ignored if new text is equal
12631306
* gets ignored if the type has not changed
12641307
* gets ignored if new html is equal
12651308

1309+
src/renderers/shared/shared/__tests__/ReactChildReconciler-test.js
1310+
* warns for duplicated array keys
1311+
* warns for duplicated array keys with component stack info
1312+
* warns for duplicated iterable keys
1313+
* warns for duplicated iterable keys with component stack info
1314+
12661315
src/renderers/shared/shared/__tests__/ReactComponent-test.js
12671316
* should throw when supplying a ref outside of render method
12681317
* should warn when children are mutated during render
@@ -1317,6 +1366,7 @@ src/renderers/shared/shared/__tests__/ReactCompositeComponent-test.js
13171366
* should replace state
13181367
* should support objects with prototypes as state
13191368
* should not warn about unmounting during unmounting
1369+
* should warn when mutated props are passed
13201370
* should only call componentWillUnmount once
13211371
* prepares new child before unmounting old
13221372

@@ -1405,6 +1455,8 @@ src/renderers/shared/shared/__tests__/ReactMultiChild-test.js
14051455
* should replace children with different constructors
14061456
* should NOT replace children with different owners
14071457
* should replace children with different keys
1458+
* should warn for duplicated array keys with component stack info
1459+
* should warn for duplicated iterable keys with component stack info
14081460
* should reorder bailed-out children
14091461
* prepares new children before unmounting old
14101462

@@ -1457,6 +1509,7 @@ src/renderers/shared/shared/__tests__/ReactStatelessComponent-test.js
14571509
* should unmount stateless component
14581510
* should pass context thru stateless component
14591511
* should provide a null ref
1512+
* should use correct name in key warning
14601513
* should support default props and prop types
14611514
* should receive context
14621515
* should work with arrow functions
@@ -1511,6 +1564,8 @@ src/renderers/shared/shared/__tests__/refs-test.js
15111564
* ref called correctly for stateless component when __DEV__ = false
15121565
* ref called correctly for stateless component when __DEV__ = true
15131566
* coerces numbers to strings
1567+
* attaches, detaches from fiber component with stack layer
1568+
* attaches, detaches from stack component with fiber layer
15141569

15151570
src/renderers/shared/shared/event/__tests__/EventPluginHub-test.js
15161571
* should prevent non-function listeners, at dispatch

src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,6 @@ describe('ReactElementValidator', () => {
258258
expectDev(console.error.calls.count()).toBe(0);
259259
});
260260

261-
// TODO: These warnings currently come from the composite component, but
262-
// they should be moved into the ReactElementValidator.
263-
264261
it('should give context for PropType errors in nested components.', () => {
265262
// In this test, we're making sure that if a proptype error is found in a
266263
// component, we give a small hint as to which parent instantiated that

0 commit comments

Comments
 (0)