Skip to content

Commit 522bd31

Browse files
authored
Merge pull request #2042 from Shopify/deprecate-skia-values
Deprecates Skia values
2 parents bdb9759 + 9203a10 commit 522bd31

File tree

11 files changed

+88
-8
lines changed

11 files changed

+88
-8
lines changed

package/src/animation/spring/runSpring.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import { Spring } from "./Spring";
1010
import { createSpringEasing } from "./functions/spring";
1111

1212
/**
13+
* @deprecated Use Reanimated 3 for animations:
14+
* https://shopify.github.io/react-native-skia/docs/animations/animations
15+
*
1316
* Creates a new animation on an existing value that will be driven by
1417
* an animation value. The value will be run from / to the value in
1518
* params and modified by the provided easing curve for the length of

package/src/animation/spring/useSpring.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import { Spring } from "./Spring";
1010
import { createSpringEasing } from "./functions/spring";
1111

1212
/**
13+
* @deprecated Use Reanimated 3 for animations:
14+
* https://shopify.github.io/react-native-skia/docs/animations/animations
15+
*
1316
* Creats a spring based animation value that will run whenever
1417
* the animation parameters change.
1518
* @param toOrParams

package/src/animation/timing/runTiming.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import type {
88
import { getResolvedParams } from "./functions";
99
import { createTiming } from "./createTiming";
1010
/**
11+
* @deprecated Use Reanimated 3 for animations:
12+
* https://shopify.github.io/react-native-skia/docs/animations/animations
13+
*
1114
* Creates a new animation on an existing value that will be driven by
1215
* an animation value. The value will be run from / to the value in
1316
* params and modified by the provided easing curve for the length of

package/src/animation/timing/useLoop.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import type { TimingConfig } from "../types";
33
import { useTiming } from "./useTiming";
44

55
/**
6+
* @deprecated Use Reanimated 3 for animations:
7+
* https://shopify.github.io/react-native-skia/docs/animations/animations
8+
*
69
* Configures a looped timing value. The value will go back and forth
710
* between 0 and 1 and back.
811
* @param config Timing configuration for easing and duration

package/src/animation/timing/useTiming.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import { getResolvedParams } from "./functions";
1212
import { createTiming } from "./createTiming";
1313

1414
/**
15+
* @deprecated Use Reanimated 3 for animations:
16+
* https://shopify.github.io/react-native-skia/docs/animations/animations
17+
*
1518
* Creats an animation value that will run whenever
1619
* the animation parameters change. The animation start immediately.
1720
* @param toOrParams

package/src/values/api.ts

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,61 @@
1-
import type { ISkiaValueApi } from "./types";
1+
import type {
2+
AnimationState,
3+
ISkiaValueApi,
4+
SkiaAnimation,
5+
SkiaClockValue,
6+
SkiaMutableValue,
7+
SkiaValue,
8+
} from "./types";
29

310
declare global {
411
var SkiaValueApi: ISkiaValueApi;
512
}
613

714
const { SkiaValueApi } = global;
8-
export const ValueApi = SkiaValueApi;
15+
16+
const deprecatedWarning = () => {
17+
console.warn(
18+
`Skia values are deprecated and will be removed in the next Skia release.
19+
Please use Reanimated instead: https://shopify.github.io/react-native-skia/docs/animations/animations`
20+
);
21+
};
22+
23+
export const ValueApi = {
24+
/**
25+
* @deprecated Use Reanimated 3
26+
* for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
27+
*/
28+
createValue<T>(initialValue: T): SkiaMutableValue<T> {
29+
deprecatedWarning();
30+
return SkiaValueApi.createValue(initialValue);
31+
},
32+
/**
33+
* @deprecated Use Reanimated 3
34+
* for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
35+
*/
36+
createComputedValue<R>(
37+
cb: () => R,
38+
values: SkiaValue<unknown>[]
39+
): SkiaValue<R> {
40+
deprecatedWarning();
41+
return SkiaValueApi.createComputedValue(cb, values);
42+
},
43+
/**
44+
* @deprecated Use Reanimated 3
45+
* for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
46+
*/
47+
createClockValue(): SkiaClockValue {
48+
deprecatedWarning();
49+
return SkiaValueApi.createClockValue();
50+
},
51+
/**
52+
* @deprecated Use Reanimated 3
53+
* for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
54+
*/
55+
createAnimation<S extends AnimationState = AnimationState>(
56+
cb: (t: number, state: S | undefined) => S
57+
): SkiaAnimation {
58+
deprecatedWarning();
59+
return SkiaValueApi.createAnimation(cb);
60+
},
61+
};

package/src/values/hooks/useClockValue.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { useEffect, useMemo } from "react";
33
import { ValueApi } from "../api";
44

55
/**
6+
* @deprecated Use Reanimated 3
7+
* for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
8+
*
69
* @returns A new value that will be updated on every frame redraw with the
710
* number of milliseconds elapsed since the value was started.
811
* The clock is created in the stopped state.

package/src/values/hooks/useComputedValue.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { ValueApi } from "../api";
44
import { isValue } from "../../renderer/processors/Animations";
55

66
/**
7+
* @deprecated Use Reanimated 3
8+
* for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
9+
*
710
* Creates a new computed value - a value that will calculate its value depending
811
* on other values.
912
* @param cb Callback to calculate new value

package/src/values/hooks/useValue.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { ValueApi } from "../api";
44
import type { SkiaMutableValue } from "../types";
55

66
/**
7+
* @deprecated Use Reanimated 3
8+
* for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
9+
*
710
* Creates a new value that holds some data.
811
* @param v Value to hold
912
* @returns A Value of type of v

package/src/values/hooks/useValueEffect.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { useEffect } from "react";
33
import type { SkiaValue } from "../types";
44

55
/**
6+
* @deprecated Use Reanimated 3
7+
* for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
8+
*
69
* Sets up an effect that will be run whenever the value changes
710
* @param value Value to subscribe to changes on
811
* @param cb Callback to run when value changes

0 commit comments

Comments
 (0)