react-native-anchor-point
react-native-anchor-point copied to clipboard
Patch for 0.71.9
There has been a change in React Native 0.71.9 that changes the way transforms work, allowing string transform styles.
For now, I've excluded the type from the transform arguments to the withAnchorPoint
hook, and added a guard around the transform being an array.
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-anchor-point/index.ts b/node_modules/react-native-anchor-point/index.ts
index f789fa7..5773f5f 100644
--- a/node_modules/react-native-anchor-point/index.ts
+++ b/node_modules/react-native-anchor-point/index.ts
@@ -1,4 +1,4 @@
-import type { TransformsStyle } from "react-native";
+import type { TransformsStyle, Animated } from "react-native";
export interface Point {
x: number;
@@ -16,7 +16,10 @@ const isValidSize = (size: Size): boolean => {
const defaultAnchorPoint = { x: 0.5, y: 0.5 };
-export const withAnchorPoint = (transform: TransformsStyle, anchorPoint: Point, size: Size) => {
+export const withAnchorPoint = (
+ transform: TransformsStyle | Animated.WithAnimatedValue<TransformsStyle>,
+ anchorPoint: Point, size: Size
+) => {
if(!isValidSize(size)) {
return transform;
}
@@ -33,11 +36,14 @@ export const withAnchorPoint = (transform: TransformsStyle, anchorPoint: Point,
shiftTranslateX.push({
translateX: size.width * (anchorPoint.x - defaultAnchorPoint.x),
});
- injectedTransform = [...shiftTranslateX, ...injectedTransform];
- // shift after rotation
- injectedTransform.push({
- translateX: size.width * (defaultAnchorPoint.x - anchorPoint.x),
- });
+
+ if (Array.isArray(injectedTransform)) {
+ injectedTransform = [...shiftTranslateX, ...injectedTransform];
+ // shift after rotation
+ injectedTransform.push({
+ translateX: size.width * (defaultAnchorPoint.x - anchorPoint.x),
+ });
+ }
}
if (!Array.isArray(injectedTransform)) {
This issue body was partially generated by patch-package.