15
15
16
16
var invariant = require ( 'invariant' ) ;
17
17
var ReactFiberReconciler = require ( 'ReactFiberReconciler' ) ;
18
- var ReactTestFiberComponent = require ( 'ReactTestFiberComponent' ) ;
19
18
20
19
import type { ReactElement } from 'ReactElementType' ;
21
20
import type { ReactInstance } from 'ReactInstanceType' ;
@@ -27,11 +26,35 @@ type ReactTestRendererJSON = {
27
26
$$typeof ? : any
28
27
}
29
28
30
- var {
31
- createElement,
32
- setInitialProperties,
33
- updateProperties,
34
- } = ReactTestFiberComponent ;
29
+ let instanceCounter = 0 ;
30
+ var createElement = ( type , rawProps , rootContainerInstance ) => {
31
+ const { children, ...props } = rawProps ;
32
+ var inst = {
33
+ id : instanceCounter ++ ,
34
+ type : type ,
35
+ children : typeof children === 'undefined' ? null : Array . isArray ( children ) ? children : [ children ] ,
36
+ props : props ,
37
+ } ;
38
+ // Hide from unit tests
39
+ Object . defineProperty ( inst , 'id' , { value : inst . id , enumerable : false } ) ;
40
+ Object . defineProperty ( inst , '$$typeof' , {
41
+ value : Symbol . for ( 'react.test.json' ) ,
42
+ } ) ;
43
+ // todo: something like this?
44
+ // const mockInst = rootContainerInstance.createNodeMock(inst);
45
+ return inst ;
46
+ } ;
47
+
48
+ var setInitialProperties = ( ) => {
49
+ throw new Error ( 'TODO: setInitialProperties' ) ;
50
+ } ;
51
+
52
+ var updateProperties = ( element , type , oldProps , newProps ) => {
53
+ const { children, ...props } = newProps ;
54
+ element . type = type ;
55
+ element . props = props ;
56
+ element . children = typeof children === 'undefined' ? null : Array . isArray ( children ) ? children : [ children ] ;
57
+ } ;
35
58
36
59
var TestRenderer = ReactFiberReconciler ( {
37
60
getRootHostContext ( rootContainerInstance : Container ) : HostContext {
0 commit comments