Commit 668fbd6
authored
Fix serial passive effects (#15650)
* Failing test for false positive warning
* Flush passive effects before discrete events
Currently, we check for pending passive effects inside the `setState`
method before we add additional updates to the queue, in case those
pending effects also add things to the queue.
However, the `setState` method is too late, because the event that
caused the update might not have ever fired had the passive effects
flushed before we got there.
This is the same as the discrete/serial events problem. When a serial
update comes in, and there's already a pending serial update, we have to
do it before we call the user-provided event handlers. Because the event
handlers themselves might change as a result of the pending update.
This commit moves the `flushPassiveEffects` call to before the discrete
event handlers are called, and removes it from the `setState` method.
Non-discrete events will not cause passive effects to flush, which is
fine, since by definition they are not order dependent.1 parent b0657fd commit 668fbd6
File tree
7 files changed
+76
-61
lines changed- packages
- react-dom/src/__tests__
- react-reconciler/src
- __tests__
7 files changed
+76
-61
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | 75 | | |
112 | 76 | | |
113 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
| |||
194 | 193 | | |
195 | 194 | | |
196 | 195 | | |
197 | | - | |
198 | 196 | | |
199 | 197 | | |
200 | 198 | | |
| |||
214 | 212 | | |
215 | 213 | | |
216 | 214 | | |
217 | | - | |
218 | 215 | | |
219 | 216 | | |
220 | 217 | | |
| |||
233 | 230 | | |
234 | 231 | | |
235 | 232 | | |
236 | | - | |
237 | 233 | | |
238 | 234 | | |
239 | 235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
| |||
1108 | 1107 | | |
1109 | 1108 | | |
1110 | 1109 | | |
1111 | | - | |
1112 | | - | |
1113 | 1110 | | |
1114 | 1111 | | |
1115 | 1112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
156 | 155 | | |
157 | 156 | | |
158 | 157 | | |
| |||
392 | 391 | | |
393 | 392 | | |
394 | 393 | | |
395 | | - | |
396 | | - | |
397 | 394 | | |
398 | 395 | | |
399 | 396 | | |
| |||
411 | 408 | | |
412 | 409 | | |
413 | 410 | | |
414 | | - | |
415 | 411 | | |
416 | 412 | | |
417 | 413 | | |
| |||
420 | 416 | | |
421 | 417 | | |
422 | 418 | | |
423 | | - | |
424 | 419 | | |
425 | 420 | | |
426 | 421 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
560 | 560 | | |
561 | 561 | | |
562 | 562 | | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
563 | 566 | | |
564 | 567 | | |
565 | 568 | | |
| |||
595 | 598 | | |
596 | 599 | | |
597 | 600 | | |
| 601 | + | |
| 602 | + | |
598 | 603 | | |
599 | 604 | | |
600 | 605 | | |
| |||
Lines changed: 52 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1719 | 1719 | | |
1720 | 1720 | | |
1721 | 1721 | | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
1722 | 1774 | | |
1723 | 1775 | | |
1724 | 1776 | | |
| |||
Lines changed: 19 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
670 | 670 | | |
671 | 671 | | |
672 | 672 | | |
673 | | - | |
674 | | - | |
| 673 | + | |
675 | 674 | | |
676 | 675 | | |
677 | 676 | | |
| |||
776 | 775 | | |
777 | 776 | | |
778 | 777 | | |
779 | | - | |
| 778 | + | |
780 | 779 | | |
781 | 780 | | |
| 781 | + | |
| 782 | + | |
782 | 783 | | |
783 | | - | |
784 | 784 | | |
785 | 785 | | |
786 | 786 | | |
| |||
849 | 849 | | |
850 | 850 | | |
851 | 851 | | |
852 | | - | |
853 | | - | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
854 | 856 | | |
855 | 857 | | |
856 | 858 | | |
| |||
862 | 864 | | |
863 | 865 | | |
864 | 866 | | |
865 | | - | |
| 867 | + | |
866 | 868 | | |
867 | 869 | | |
868 | 870 | | |
| |||
880 | 882 | | |
881 | 883 | | |
882 | 884 | | |
883 | | - | |
| 885 | + | |
884 | 886 | | |
885 | | - | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
886 | 890 | | |
887 | 891 | | |
888 | 892 | | |
889 | 893 | | |
890 | 894 | | |
891 | | - | |
| 895 | + | |
892 | 896 | | |
893 | 897 | | |
894 | 898 | | |
| |||
929 | 933 | | |
930 | 934 | | |
931 | 935 | | |
932 | | - | |
| 936 | + | |
933 | 937 | | |
934 | | - | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
935 | 941 | | |
936 | 942 | | |
937 | 943 | | |
| |||
1472 | 1478 | | |
1473 | 1479 | | |
1474 | 1480 | | |
1475 | | - | |
1476 | 1481 | | |
| 1482 | + | |
1477 | 1483 | | |
1478 | 1484 | | |
1479 | 1485 | | |
| |||
0 commit comments