File tree 2 files changed +47
-5
lines changed
2 files changed +47
-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
+ // key was skipped
109
111
}
110
112
}
111
113
} )
Original file line number Diff line number Diff line change @@ -264,6 +264,46 @@ 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
+ const proxy = createProxy ( BaseClass )
283
+ const Proxy = proxy . get ( )
284
+ const instance = new Proxy ( )
285
+ expect ( instance . render ( ) ) . toBe ( 42 )
286
+
287
+ {
288
+ const externalValue = 24
289
+ class Update1Class extends React . Component {
290
+ arrow = ( ) => externalValue
291
+
292
+ render ( ) {
293
+ return this . arrow ( )
294
+ }
295
+
296
+ __reactstandin__regenerateByEval ( key , code ) {
297
+ this [ key ] = eval ( code )
298
+ }
299
+ }
300
+ proxy . update ( Update1Class )
301
+ }
302
+ /* eslint-enable */
303
+
304
+ expect ( instance . render ( ) ) . toBe ( 24 )
305
+ } )
306
+
267
307
it ( 'should stand-for all class members' , ( ) => {
268
308
class Initial {
269
309
constructor ( ) {
You can’t perform that action at this time.
0 commit comments