Skip to content

Commit 33fc353

Browse files
authored
chore: install use-latest-callback (#3746)
1 parent d2432f1 commit 33fc353

File tree

6 files changed

+12
-17
lines changed

6 files changed

+12
-17
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"dependencies": {
5151
"@callstack/react-theme-provider": "^3.0.8",
5252
"color": "^3.1.2",
53-
"use-event-callback": "^0.1.0"
53+
"use-latest-callback": "^0.1.5"
5454
},
5555
"devDependencies": {
5656
"@babel/core": "^7.20.7",

src/components/Banner.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { Animated, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
33

4-
import useEventCallback from 'use-event-callback';
4+
import useLatestCallback from 'use-latest-callback';
55

66
import { useInternalTheme } from '../core/theming';
77
import type { $RemoveChildren, ThemeProp } from '../types';
@@ -151,8 +151,8 @@ const Banner = ({
151151
measured: false,
152152
});
153153

154-
const showCallback = useEventCallback(onShowAnimationFinished);
155-
const hideCallback = useEventCallback(onHideAnimationFinished);
154+
const showCallback = useLatestCallback(onShowAnimationFinished);
155+
const hideCallback = useLatestCallback(onHideAnimationFinished);
156156

157157
const { scale } = theme.animation;
158158

src/components/BottomNavigation/BottomNavigation.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
ViewStyle,
1111
} from 'react-native';
1212

13-
import useEventCallback from 'use-event-callback';
13+
import useLatestCallback from 'use-latest-callback';
1414

1515
import { useInternalTheme } from '../../core/theming';
1616
import type { ThemeProp } from '../../types';
@@ -450,7 +450,7 @@ const BottomNavigation = ({
450450
animateToIndex(navigationState.index);
451451
}, [navigationState.index, animateToIndex, offsetsAnims]);
452452

453-
const handleTabPress = useEventCallback(
453+
const handleTabPress = useLatestCallback(
454454
(event: { route: Route } & TabPressEvent) => {
455455
onTabPress?.(event);
456456

@@ -469,7 +469,7 @@ const BottomNavigation = ({
469469
}
470470
);
471471

472-
const jumpTo = useEventCallback((key: string) => {
472+
const jumpTo = useLatestCallback((key: string) => {
473473
const index = navigationState.routes.findIndex(
474474
(route) => route.key === key
475475
);

src/components/Modal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from 'react-native';
1212

1313
import { useSafeAreaInsets } from 'react-native-safe-area-context';
14-
import useEventCallback from 'use-event-callback';
14+
import useLatestCallback from 'use-latest-callback';
1515

1616
import { useInternalTheme } from '../core/theming';
1717
import type { ThemeProp } from '../types';
@@ -118,7 +118,7 @@ function Modal({
118118
visibleRef.current = visible;
119119
});
120120

121-
const onDismissCallback = useEventCallback(onDismiss);
121+
const onDismissCallback = useLatestCallback(onDismiss);
122122

123123
const { scale } = theme.animation;
124124

src/components/Snackbar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
} from 'react-native';
1111

1212
import { useSafeAreaInsets } from 'react-native-safe-area-context';
13-
import useEventCallback from 'use-event-callback';
13+
import useLatestCallback from 'use-latest-callback';
1414

1515
import { useInternalTheme } from '../core/theming';
1616
import type { $RemoveChildren, ThemeProp } from '../types';
@@ -157,7 +157,7 @@ const Snackbar = ({
157157

158158
const { scale } = theme.animation;
159159

160-
const handleOnVisible = useEventCallback(() => {
160+
const handleOnVisible = useLatestCallback(() => {
161161
// show
162162
if (hideTimeout.current) clearTimeout(hideTimeout.current);
163163
setHidden(false);
@@ -182,7 +182,7 @@ const Snackbar = ({
182182
});
183183
});
184184

185-
const handleOnHidden = useEventCallback(() => {
185+
const handleOnHidden = useLatestCallback(() => {
186186
// hide
187187
if (hideTimeout.current) {
188188
clearTimeout(hideTimeout.current);

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11358,11 +11358,6 @@ url-parse@^1.5.3:
1135811358
querystringify "^2.1.1"
1135911359
requires-port "^1.0.0"
1136011360

11361-
use-event-callback@^0.1.0:
11362-
version "0.1.0"
11363-
resolved "https://registry.yarnpkg.com/use-event-callback/-/use-event-callback-0.1.0.tgz#29d7ce996802935c5387e7d3b606cf316da3457f"
11364-
integrity sha512-5fTzY5UEXHMK5UR0NRkUz6TPfWmmX9fO8Tx3SnHrfMPdrQ7Rna0gDBy0r56SP68TwsP9DgwSBzeysCu3A/Z2NA==
11365-
1136611361
use-latest-callback@^0.1.5:
1136711362
version "0.1.5"
1136811363
resolved "https://registry.yarnpkg.com/use-latest-callback/-/use-latest-callback-0.1.5.tgz#a4a836c08fa72f6608730b5b8f4bbd9c57c04f51"

0 commit comments

Comments
 (0)