A framework for building native applications using React
chore: Clear timer functions do noting when a timer does not exist (#55126)
Summary:
Issue: https://github.com/facebook/react-native/issues/55104
## Changelog:
[GENERAL] [CHANGED] - `cancelAnimationFrame`, `clearImmediate`, `clearTimeout` and `clearInterval` do nothing If there is no callback associated the given handle
Pull Request resolved: https://github.com/facebook/react-native/pull/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: e5102a137bac6492d0f89bb02ef11eeca9977a9b D
D N committed
9d3cc383ba9b45ef28721a1ae81b2d0429363bf5
Parent: cd3a9c5
Committed by meta-codesync[bot] <215208954+meta-codesync[bot]@users.noreply.github.com>
on 1/16/2026, 2:14:46 AM