Commit c1f5884
authored
Add missing null checks to OffscreenInstance code (#24846)
`stateNode` is any-typed, so when reading from `stateNode` we should always cast
it to the specific type for that type of work. I noticed a place in the commit
phase where OffscreenInstance wasn't being cast. When I added the type
assertion, it exposed some type errors where nullable values were being accessed
without first being refined.
I added the required null checks without verifying the logic of the existing
code. If the existing logic was correct, then the extra null checks won't have
any affect on the behavior, because all they do is refine from a nullable type
to a non-nullable type in places where the type was assumed to already be
non-nullable. But the result looks a bit fishy to me, so I also left behind some
TODOs to follow up and verify it's correct.1 parent 4cd788a commit c1f5884
File tree
4 files changed
+50
-16
lines changed- packages/react-reconciler/src
4 files changed
+50
-16
lines changedLines changed: 24 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
2877 | 2878 | | |
2878 | 2879 | | |
2879 | 2880 | | |
2880 | | - | |
2881 | | - | |
| 2881 | + | |
| 2882 | + | |
2882 | 2883 | | |
2883 | 2884 | | |
2884 | 2885 | | |
| |||
2896 | 2897 | | |
2897 | 2898 | | |
2898 | 2899 | | |
2899 | | - | |
| 2900 | + | |
| 2901 | + | |
| 2902 | + | |
| 2903 | + | |
| 2904 | + | |
2900 | 2905 | | |
2901 | 2906 | | |
2902 | 2907 | | |
| |||
2913 | 2918 | | |
2914 | 2919 | | |
2915 | 2920 | | |
2916 | | - | |
2917 | | - | |
2918 | | - | |
2919 | | - | |
| 2921 | + | |
| 2922 | + | |
| 2923 | + | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
| 2929 | + | |
| 2930 | + | |
| 2931 | + | |
| 2932 | + | |
| 2933 | + | |
| 2934 | + | |
| 2935 | + | |
| 2936 | + | |
2920 | 2937 | | |
2921 | 2938 | | |
2922 | 2939 | | |
| |||
Lines changed: 24 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
2877 | 2878 | | |
2878 | 2879 | | |
2879 | 2880 | | |
2880 | | - | |
2881 | | - | |
| 2881 | + | |
| 2882 | + | |
2882 | 2883 | | |
2883 | 2884 | | |
2884 | 2885 | | |
| |||
2896 | 2897 | | |
2897 | 2898 | | |
2898 | 2899 | | |
2899 | | - | |
| 2900 | + | |
| 2901 | + | |
| 2902 | + | |
| 2903 | + | |
| 2904 | + | |
2900 | 2905 | | |
2901 | 2906 | | |
2902 | 2907 | | |
| |||
2913 | 2918 | | |
2914 | 2919 | | |
2915 | 2920 | | |
2916 | | - | |
2917 | | - | |
2918 | | - | |
2919 | | - | |
| 2921 | + | |
| 2922 | + | |
| 2923 | + | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
| 2929 | + | |
| 2930 | + | |
| 2931 | + | |
| 2932 | + | |
| 2933 | + | |
| 2934 | + | |
| 2935 | + | |
| 2936 | + | |
2920 | 2937 | | |
2921 | 2938 | | |
2922 | 2939 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
0 commit comments