File tree 2 files changed +48
-5
lines changed
2 files changed +48
-5
lines changed Original file line number Diff line number Diff line change @@ -81,15 +81,15 @@ function mergeComponents(
81
81
82
82
const nextString = String ( nextAttr )
83
83
const injectedBefore = injectedMembers [ key ]
84
+ const isFunction =
85
+ nextString . indexOf ( 'function' ) >= 0 || nextString . indexOf ( '=>' ) >= 0
84
86
if (
85
87
nextString !== String ( prevAttr ) ||
86
- ( injectedBefore && nextString !== String ( injectedBefore ) )
88
+ ( injectedBefore && nextString !== String ( injectedBefore ) ) ||
89
+ isFunction
87
90
) {
88
91
if ( ! hasRegenerate ) {
89
- if (
90
- nextString . indexOf ( 'function' ) < 0 &&
91
- nextString . indexOf ( '=>' ) < 0
92
- ) {
92
+ if ( ! isFunction ) {
93
93
// just copy prop over
94
94
injectedCode [ key ] = nextAttr
95
95
} else {
@@ -106,6 +106,8 @@ function mergeComponents(
106
106
} else {
107
107
injectedCode [ key ] = nextAttr
108
108
}
109
+ } else {
110
+ //console.warn('skipped',key, nextString);
109
111
}
110
112
}
111
113
} )
Original file line number Diff line number Diff line change @@ -264,6 +264,47 @@ describe('consistency', () => {
264
264
expect ( instance . render ( ) ) . toBe ( 42 )
265
265
} )
266
266
267
+ it ( 'should reflect external dependencies' , ( ) => {
268
+ /* eslint-disable */
269
+ const externalValue = 42
270
+ class BaseClass extends React . Component {
271
+ arrow = ( ) => externalValue
272
+
273
+ render ( ) {
274
+ return this . arrow ( )
275
+ }
276
+
277
+ __reactstandin__regenerateByEval ( key , code ) {
278
+ this [ key ] = eval ( code )
279
+ }
280
+ }
281
+
282
+ /* eslint-enable */
283
+
284
+ const proxy = createProxy ( BaseClass )
285
+ const Proxy = proxy . get ( )
286
+ const instance = new Proxy ( )
287
+ expect ( instance . render ( ) ) . toBe ( 42 )
288
+
289
+ {
290
+ const externalValue = 24
291
+ class Update1Class extends React . Component {
292
+ arrow = ( ) => externalValue
293
+
294
+ render ( ) {
295
+ return this . arrow ( )
296
+ }
297
+
298
+ __reactstandin__regenerateByEval ( key , code ) {
299
+ this [ key ] = eval ( code )
300
+ }
301
+ }
302
+ proxy . update ( Update1Class )
303
+ }
304
+
305
+ expect ( instance . render ( ) ) . toBe ( 24 )
306
+ } )
307
+
267
308
it ( 'should stand-for all class members' , ( ) => {
268
309
class Initial {
269
310
constructor ( ) {
You can’t perform that action at this time.
0 commit comments