Commit 66267d0
committed
useDeferredValue switches to final if initial suspends
If a parent render spawns a deferred task with useDeferredValue, but
the parent render suspends, we should not wait for the parent render to
complete before attempting to render the final value.
The reason is that the initialValue argument to useDeferredValue is
meant to represent an immediate preview of the final UI. If we can't
render it "immediately", we might as well skip it and go straight to
the "real" value.
This is an improvement over how a userspace implementation of
useDeferredValue would work, because a userspace implementation would
have to wait for the parent task to commit (useEffect) before spawning
the deferred task, creating a waterfall.1 parent d6443ed commit 66267d0
File tree
7 files changed
+438
-66
lines changed- packages
- react-reconciler/src
- __tests__
7 files changed
+438
-66
lines changedLines changed: 26 additions & 26 deletions
Large diffs are not rendered by default.
Lines changed: 12 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2001 | 2001 | | |
2002 | 2002 | | |
2003 | 2003 | | |
2004 | | - | |
| 2004 | + | |
2005 | 2005 | | |
2006 | 2006 | | |
2007 | 2007 | | |
2008 | | - | |
2009 | | - | |
2010 | | - | |
2011 | | - | |
2012 | | - | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
2013 | 2013 | | |
2014 | 2014 | | |
2015 | 2015 | | |
| |||
2269 | 2269 | | |
2270 | 2270 | | |
2271 | 2271 | | |
2272 | | - | |
| 2272 | + | |
2273 | 2273 | | |
2274 | 2274 | | |
2275 | 2275 | | |
2276 | | - | |
2277 | | - | |
2278 | | - | |
2279 | | - | |
2280 | | - | |
| 2276 | + | |
| 2277 | + | |
| 2278 | + | |
| 2279 | + | |
| 2280 | + | |
2281 | 2281 | | |
2282 | 2282 | | |
2283 | 2283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
68 | | - | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| 105 | + | |
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
| |||
2665 | 2667 | | |
2666 | 2668 | | |
2667 | 2669 | | |
2668 | | - | |
| 2670 | + | |
| 2671 | + | |
2669 | 2672 | | |
2670 | 2673 | | |
2671 | | - | |
2672 | | - | |
2673 | | - | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
2674 | 2681 | | |
2675 | 2682 | | |
2676 | | - | |
2677 | | - | |
| 2683 | + | |
| 2684 | + | |
2678 | 2685 | | |
2679 | 2686 | | |
2680 | 2687 | | |
| |||
2710 | 2717 | | |
2711 | 2718 | | |
2712 | 2719 | | |
2713 | | - | |
| 2720 | + | |
2714 | 2721 | | |
2715 | 2722 | | |
2716 | 2723 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
622 | 622 | | |
623 | 623 | | |
624 | 624 | | |
625 | | - | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
626 | 630 | | |
627 | 631 | | |
628 | 632 | | |
| |||
637 | 641 | | |
638 | 642 | | |
639 | 643 | | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
640 | 648 | | |
641 | 649 | | |
642 | 650 | | |
643 | 651 | | |
644 | 652 | | |
645 | 653 | | |
646 | | - | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
647 | 659 | | |
648 | 660 | | |
649 | 661 | | |
| |||
689 | 701 | | |
690 | 702 | | |
691 | 703 | | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
692 | 735 | | |
693 | 736 | | |
694 | 737 | | |
| |||
0 commit comments