@@ -6,6 +6,8 @@ import componentPath from '../common/componentPath';
6
6
import ComponentContext , {
7
7
ComponentContextValue ,
8
8
} from '../common/ComponentContext' ;
9
+ import Input from './native/Input' ;
10
+ import { noop } from '../common/utils' ;
9
11
10
12
const componentClassCache : Record < string , React . ComponentClass > = { } ;
11
13
@@ -37,19 +39,12 @@ export function getComponentClass(name: string): React.ComponentClass {
37
39
state : { } ,
38
40
} ;
39
41
Object . defineProperty ( this . publicInstance , 'props' , {
40
- get : ( ) => {
41
- return this . props ;
42
- } ,
42
+ get : this . getInstanceProps ,
43
43
} ) ;
44
44
Object . defineProperty ( this . publicInstance , 'state' , {
45
- get : ( ) => {
46
- return this . state . state ;
47
- } ,
45
+ get : this . getInstanceState ,
48
46
} ) ;
49
47
}
50
- callMethod ( ) {
51
- return ;
52
- }
53
48
static getDerivedStateFromProps ( _ : any , { __self } : any ) {
54
49
const instance : Component = __self ;
55
50
componentPath . updateComponentPath ( instance ) ;
@@ -68,6 +63,12 @@ export function getComponentClass(name: string): React.ComponentClass {
68
63
return { } ;
69
64
}
70
65
66
+ getInstanceProps = ( ) => {
67
+ return this . props ;
68
+ } ;
69
+ getInstanceState ( ) {
70
+ return this . state . state ;
71
+ }
71
72
getContext ( ) {
72
73
return this . context as ComponentContextValue ;
73
74
}
@@ -76,6 +77,8 @@ export function getComponentClass(name: string): React.ComponentClass {
76
77
componentSpec . componentDidMount ?. call ( this . publicInstance ) ;
77
78
}
78
79
80
+ callMethod = noop ;
81
+
79
82
componentDidUpdate ( prevProps : any , prevState : any ) {
80
83
const { publicInstance } = this ;
81
84
componentSpec . componentDidUpdate ?. call (
@@ -104,6 +107,7 @@ export function getComponentClass(name: string): React.ComponentClass {
104
107
} ;
105
108
app . postMessage ( msg ) ;
106
109
} ;
110
+ ( nativeEventHandles as any ) . handleName = name ;
107
111
return nativeEventHandles [ name ] ;
108
112
} ;
109
113
@@ -112,13 +116,13 @@ export function getComponentClass(name: string): React.ComponentClass {
112
116
} ;
113
117
114
118
render ( ) : React . ReactNode {
115
- const element = componentSpec . render ( {
119
+ const element = componentSpec . render . call ( {
116
120
native : nativeComponents ,
117
121
props : this . props ,
118
122
state : this . state . state ,
119
123
getNativeEventHandle : this . getNativeEventHandle ,
120
124
getComponentEventHandle : this . getComponentEventHandle ,
121
- getComponentClass,
125
+ getComponent : getComponentClass ,
122
126
} ) ;
123
127
return componentPath . renderWithComponentContext ( this , element ) ;
124
128
}
@@ -130,3 +134,7 @@ export function getComponentClass(name: string): React.ComponentClass {
130
134
componentClassCache [ name ] = C ;
131
135
return C ;
132
136
}
137
+
138
+ Object . assign ( nativeComponents , {
139
+ input : ( Input as any ) || getComponentClass ( 'input' ) ,
140
+ } ) ;
0 commit comments