Commit 9d3cc38
chore: Clear timer functions do noting when a timer does not exist (#55126)
Summary:
Issue: #55104
## Changelog:
[GENERAL] [CHANGED] - `cancelAnimationFrame`, `clearImmediate`, `clearTimeout` and `clearInterval` do nothing If there is no callback associated the given handle
Pull Request resolved: #55126
Test Plan:
The next code should not throw any errors (runtime and TS)
```tsx
const id1 = requestAnimationFrame(()=> {});
cancelAnimationFrame(id1);
cancelAnimationFrame(id1); // clear twice the same id
cancelAnimationFrame(-1);
cancelAnimationFrame(null);
cancelAnimationFrame(undefined);
const id2 = setImmediate(()=> {});
clearImmediate(id2);
clearImmediate(id2); // clear twice the same id
clearImmediate(-1);
clearImmediate(null);
clearImmediate(undefined);
const id3 = setTimeout(()=> {}, 1000);
clearTimeout(id3);
clearTimeout(id3); // clear twice the same id
clearTimeout(-1);
clearTimeout(null);
clearTimeout(undefined);
const id4 = setInterval(()=> {}, 1000);
clearInterval(id4);
clearInterval(id4); // clear twice the same id
clearInterval(-1);
clearInterval(null);
clearInterval(undefined);
```
Reviewed By: cortinico
Differential Revision: D90615301
Pulled By: philIip
fbshipit-source-id: e5102a137bac6492d0f89bb02ef11eeca9977a9b1 parent cd3a9c5 commit 9d3cc38
3 files changed
Lines changed: 60 additions & 6 deletions
File tree
- packages/react-native
- ReactCommon/react/runtime
- src/types
- types/__typetests__
Lines changed: 16 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
138 | 146 | | |
139 | 147 | | |
140 | 148 | | |
| |||
145 | 153 | | |
146 | 154 | | |
147 | 155 | | |
148 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
149 | 163 | | |
150 | 164 | | |
151 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | | - | |
| 104 | + | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
41 | 47 | | |
42 | 48 | | |
43 | 49 | | |
| |||
68 | 74 | | |
69 | 75 | | |
70 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
71 | 80 | | |
72 | 81 | | |
73 | 82 | | |
| |||
97 | 106 | | |
98 | 107 | | |
99 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
100 | 140 | | |
101 | 141 | | |
102 | 142 | | |
| |||
0 commit comments