Skip to content

Commit 3df1de8

Browse files
danielwinklerdanielwinklermedelgorhom
authored
feat: added Reanimated v2 compatibility (by @danielwinkler)
* feat(rna2): allow rn reanimated v2 peer dependency * chore: refactor code * chore: updated redash for example Co-authored-by: Daniel Winkler <[email protected]> Co-authored-by: Mo Gorhom <[email protected]>
1 parent 367e19a commit 3df1de8

20 files changed

+54
-30
lines changed

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"react-native": "0.63.3",
2020
"react-native-gesture-handler": "^1.8.0",
2121
"react-native-reanimated": "1.13.1",
22-
"react-native-redash": "^14.2.4",
22+
"react-native-redash": "^15.7.3",
2323
"react-native-safe-area-context": "^3.1.8",
2424
"react-native-screens": "^2.11.0",
2525
"react-native-svg": "^12.1.0"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
},
3939
"dependencies": {
4040
"lodash.isequal": "^4.5.0",
41-
"react-native-redash": "^14.2.1"
41+
"react-native-redash": "15.7.3"
4242
},
4343
"devDependencies": {
4444
"@commitlint/cli": "^9.1.1",

src/AnimatedTabBar.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@ import React, { useMemo, useCallback, useEffect, useRef } from 'react';
22
import type { LayoutChangeEvent } from 'react-native';
33
import { useSafeArea } from 'react-native-safe-area-context';
44
import { AnimatedTabBarView } from './AnimatedTabBarView';
5-
import { useStableCallback } from './utilities';
6-
import { useTabBarVisibility } from './hooks';
5+
import { interpolate } from './utilities';
6+
import { useTabBarVisibility, useStableCallback } from './hooks';
77
import type { PresetEnum } from './presets';
88
import type { AnimatedTabBarProps } from './types';
99
import Animated, {
10-
interpolate,
1110
Extrapolate,
1211
useCode,
1312
cond,
1413
eq,
1514
call,
1615
onChange,
1716
} from 'react-native-reanimated';
18-
import { useValue } from 'react-native-redash';
17+
import { useValue } from 'react-native-redash/lib/module/v1';
1918

2019
interface Route {
2120
name: string;

src/AnimatedTabBarView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useMemo, useEffect, useRef } from 'react';
22
import Animated from 'react-native-reanimated';
3-
import { useValue } from 'react-native-redash';
3+
import { useValue } from 'react-native-redash/lib/module/v1';
44
import Presets, { PresetEnum } from './presets';
55
import type { AnimatedTabBarViewProps } from './types';
66

src/components/rawButton/RawButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import {
1111
TapGestureHandler,
1212
LongPressGestureHandler,
1313
} from 'react-native-gesture-handler';
14-
import { useValue, useGestureHandler } from 'react-native-redash';
15-
import { useStableCallback } from '../../utilities';
14+
import { useValue, useGestureHandler } from 'react-native-redash/lib/module/v1';
15+
import { useStableCallback } from '../../hooks';
1616

1717
const { useCode, cond, onChange, eq } = Animated;
1818

src/hooks/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export { useTabBarVisibility } from './useTabBarVisibility';
22
export { useTabBarItemFocusTransition } from './useTabBarItemFocusTransition';
33
export { useTabBarItemSpacing } from './useTabBarItemSpacing';
4+
export { useStableCallback } from './useStableCallback';

src/utilities.ts renamed to src/hooks/useStableCallback.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { useRef, useCallback, useEffect } from 'react';
22

3-
export const noop = () => {};
3+
type Callback = (...args: any[]) => any;
44

55
/**
66
* Provide a stable version of useCallback
77
* https://gist.github.com/JakeCoxon/c7ebf6e6496f8468226fd36b596e1985
88
*/
9-
type Callback = (...args: any[]) => any;
109
export const useStableCallback = (callback: Callback) => {
1110
const callbackRef = useRef<Callback>();
1211
const memoCallback = useCallback(

src/hooks/useTabBarVisibility.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import Animated, {
1010
clockRunning,
1111
startClock,
1212
timing,
13-
Easing,
1413
} from 'react-native-reanimated';
15-
import { useClock, useValue } from 'react-native-redash';
14+
import { useClock, useValue } from 'react-native-redash/lib/module/v1';
15+
import { Easing } from '../utilities';
1616

1717
export const useTabBarVisibility = (shouldShowTabBar: boolean) => {
1818
const _shouldShowTabBar = useValue(shouldShowTabBar ? 1 : 0);

src/presets/bubble/constants.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import Animated, { Easing } from 'react-native-reanimated';
1+
import { Easing } from '../../utilities';
22

3-
const DEFAULT_ITEM_ANIMATION_EASING: Animated.EasingFunction = Easing.out(
4-
Easing.exp
5-
);
3+
const DEFAULT_ITEM_ANIMATION_EASING = Easing.out(Easing.exp);
64
const DEFAULT_ITEM_ANIMATION_DURATION = 500;
75
const DEFAULT_ITEM_INNER_SPACE = 12;
86
const DEFAULT_ITEM_OUTER_SPACE = 12;

src/presets/bubble/item/BubbleTabBarItem.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import React, { useMemo, memo } from 'react';
22
import { View, Text, LayoutChangeEvent } from 'react-native';
33
import Animated from 'react-native-reanimated';
4-
import { interpolateColor, useValue } from 'react-native-redash';
4+
import { interpolateColor, useValue } from 'react-native-redash/lib/module/v1';
55
// @ts-ignore 😞
66
import isEqual from 'lodash.isequal';
7+
import { interpolate } from '../../../utilities';
78
import type { BubbleTabBarItemProps } from '../types';
89
import { styles } from './styles';
910

10-
const { add, interpolate } = Animated;
11+
const { add } = Animated;
1112

1213
const BubbleTabBarItemComponent = ({
1314
animatedFocus,

0 commit comments

Comments
 (0)