Commit 996e4c0
Offscreen add attach (#25603)
`Offscreen.attach` is imperative API to signal to Offscreen that its
updates should be high priority and effects should be mounted. Coupled
with `Offscreen.detach` it gives ability to manually control Offscreen.
Unlike with mode `visible` and `hidden`, it is developers job to make
sure contents of Offscreen are not visible to users.
`Offscreen.attach` only works if mode is `manual`.
Example uses:
```jsx
let offscreenRef = useRef(null);
<Offscreen mode={'manual'} ref={offscreenRef)}>
<Child />
</Offscreen>
// ------
// Offscreen is attached by default.
// For example user scrolls away and Offscreen subtree is not visible anymore.
offscreenRef.current.detach();
// User scrolls back and Offscreen subtree is visible again.
offscreenRef.current.attach();
```
Co-authored-by: Andrew Clark <[email protected]>1 parent b14d7fa commit 996e4c0
File tree
5 files changed
+372
-43
lines changed- packages/react-reconciler/src
- __tests__
5 files changed
+372
-43
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
111 | 114 | | |
112 | 115 | | |
113 | 116 | | |
| |||
750 | 753 | | |
751 | 754 | | |
752 | 755 | | |
| 756 | + | |
753 | 757 | | |
754 | 758 | | |
755 | 759 | | |
756 | 760 | | |
757 | 761 | | |
| 762 | + | |
758 | 763 | | |
759 | 764 | | |
760 | 765 | | |
| |||
773 | 778 | | |
774 | 779 | | |
775 | 780 | | |
| 781 | + | |
776 | 782 | | |
777 | 783 | | |
778 | 784 | | |
779 | 785 | | |
780 | 786 | | |
| 787 | + | |
781 | 788 | | |
782 | 789 | | |
783 | 790 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
677 | 677 | | |
678 | 678 | | |
679 | 679 | | |
| 680 | + | |
| 681 | + | |
680 | 682 | | |
681 | 683 | | |
682 | 684 | | |
| |||
687 | 689 | | |
688 | 690 | | |
689 | 691 | | |
690 | | - | |
691 | | - | |
| 692 | + | |
692 | 693 | | |
693 | 694 | | |
694 | 695 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
152 | 153 | | |
153 | 154 | | |
154 | 155 | | |
155 | | - | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
173 | 172 | | |
174 | 173 | | |
175 | 174 | | |
| |||
205 | 204 | | |
206 | 205 | | |
207 | 206 | | |
| 207 | + | |
| 208 | + | |
208 | 209 | | |
209 | 210 | | |
210 | 211 | | |
| |||
2407 | 2408 | | |
2408 | 2409 | | |
2409 | 2410 | | |
2410 | | - | |
2411 | | - | |
| 2411 | + | |
| 2412 | + | |
2412 | 2413 | | |
2413 | 2414 | | |
2414 | 2415 | | |
2415 | 2416 | | |
2416 | 2417 | | |
2417 | | - | |
2418 | | - | |
2419 | | - | |
2420 | | - | |
2421 | | - | |
2422 | | - | |
2423 | | - | |
2424 | | - | |
2425 | | - | |
2426 | | - | |
2427 | | - | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
2428 | 2449 | | |
2429 | 2450 | | |
2430 | 2451 | | |
| |||
2857 | 2878 | | |
2858 | 2879 | | |
2859 | 2880 | | |
| 2881 | + | |
| 2882 | + | |
| 2883 | + | |
2860 | 2884 | | |
2861 | | - | |
| 2885 | + | |
2862 | 2886 | | |
2863 | | - | |
2864 | | - | |
| 2887 | + | |
| 2888 | + | |
| 2889 | + | |
| 2890 | + | |
| 2891 | + | |
2865 | 2892 | | |
| 2893 | + | |
2866 | 2894 | | |
2867 | 2895 | | |
2868 | 2896 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
62 | | - | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| |||
0 commit comments