Skip to content

Commit 916f0d2

Browse files
TrySoundemmatown
authored andcommitted
Replace raf package with requestAnimationFrame (#3644)
* Replace raf package with requestAnimationFrame Not polyfilled requestAnimationFrame already used here https://github.com/JedWatson/react-select/blob/master/packages/react-select/src/animated/transitions.js#L88 `animatedScrollTo` is never called in node so polyfilling for node does not make sense too. This removed two commonjs packages from user bundlers: raf and performance-now. * Update odd-pots-smile.md
1 parent 57a6539 commit 916f0d2

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

.changeset/odd-pots-smile.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-select": patch
3+
---
4+
5+
Remove usage of `raf` package and replace with `window.requestAnimationFrame` because React already depends on `requestAnimationFrame`

packages/react-select/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"@emotion/css": "^10.0.9",
1919
"memoize-one": "^5.0.0",
2020
"prop-types": "^15.6.0",
21-
"raf": "^3.4.0",
2221
"react-input-autosize": "^2.2.2",
2322
"react-transition-group": "^2.2.1"
2423
},

packages/react-select/src/utils.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// @flow
22

3-
import raf from 'raf';
43
import { type ElementRef } from 'react';
54
import type {
65
ClassNamesState,
@@ -176,7 +175,7 @@ export function animatedScrollTo(
176175
const val = easeOutCubic(currentTime, start, change, duration);
177176
scrollTo(element, val);
178177
if (currentTime < duration) {
179-
raf(animateScroll);
178+
window.requestAnimationFrame(animateScroll);
180179
} else {
181180
callback(element);
182181
}

0 commit comments

Comments
 (0)