File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -324,4 +324,34 @@ describe('renderer: component', () => {
324
324
expect ( serializeInner ( root ) ) . toBe ( `` )
325
325
expect ( ids ) . toEqual ( [ ids [ 0 ] , ids [ 0 ] + 1 , ids [ 0 ] + 2 ] )
326
326
} )
327
+
328
+ test ( 'child component props update should not lead to double update' , async ( ) => {
329
+ const text = ref ( 0 )
330
+ const spy = jest . fn ( )
331
+
332
+ const App = {
333
+ render ( ) {
334
+ return h ( Comp , { text : text . value } )
335
+ }
336
+ }
337
+
338
+ const Comp = {
339
+ props : [ 'text' ] ,
340
+ render ( this : any ) {
341
+ spy ( )
342
+ return h ( 'h1' , this . text )
343
+ }
344
+ }
345
+
346
+ const root = nodeOps . createElement ( 'div' )
347
+ render ( h ( App ) , root )
348
+
349
+ expect ( serializeInner ( root ) ) . toBe ( `<h1>0</h1>` )
350
+ expect ( spy ) . toHaveBeenCalledTimes ( 1 )
351
+
352
+ text . value ++
353
+ await nextTick ( )
354
+ expect ( serializeInner ( root ) ) . toBe ( `<h1>1</h1>` )
355
+ expect ( spy ) . toHaveBeenCalledTimes ( 2 )
356
+ } )
327
357
} )
Original file line number Diff line number Diff line change @@ -1458,15 +1458,16 @@ function baseCreateRenderer(
1458
1458
pushWarningContext ( next || instance . vnode )
1459
1459
}
1460
1460
1461
+ // Disallow component effect recursion during pre-lifecycle hooks.
1462
+ effect . allowRecurse = false
1463
+
1461
1464
if ( next ) {
1462
1465
next . el = vnode . el
1463
1466
updateComponentPreRender ( instance , next , optimized )
1464
1467
} else {
1465
1468
next = vnode
1466
1469
}
1467
1470
1468
- // Disallow component effect recursion during pre-lifecycle hooks.
1469
- effect . allowRecurse = false
1470
1471
// beforeUpdate hook
1471
1472
if ( bu ) {
1472
1473
invokeArrayFns ( bu )
@@ -1481,6 +1482,7 @@ function baseCreateRenderer(
1481
1482
) {
1482
1483
instance . emit ( 'hook:beforeUpdate' )
1483
1484
}
1485
+
1484
1486
effect . allowRecurse = true
1485
1487
1486
1488
// render
You can’t perform that action at this time.
0 commit comments