diff --git a/apps/common-app/src/apps/reanimated/examples/GetViewPropExample.tsx b/apps/common-app/src/apps/reanimated/examples/GetViewPropExample.tsx index 4adad9d77ebd..b72796720654 100644 --- a/apps/common-app/src/apps/reanimated/examples/GetViewPropExample.tsx +++ b/apps/common-app/src/apps/reanimated/examples/GetViewPropExample.tsx @@ -1,7 +1,6 @@ import React, { useEffect } from 'react'; import { Button, StyleSheet, View } from 'react-native'; import Animated, { - getViewProp, useAnimatedRef, useAnimatedStyle, useSharedValue, @@ -25,9 +24,7 @@ export default function GetViewPropExample() { }); const handlePress = async () => { - // @ts-ignore this is fine - const viewTag = animatedRef() as number; - const result = await getViewProp(viewTag, 'opacity'); + const result = await animatedRef.getViewProp('opacity'); console.log(result); }; diff --git a/apps/common-app/src/apps/reanimated/examples/index.ts b/apps/common-app/src/apps/reanimated/examples/index.ts index 192e7e3cf297..2a0a060abfc4 100644 --- a/apps/common-app/src/apps/reanimated/examples/index.ts +++ b/apps/common-app/src/apps/reanimated/examples/index.ts @@ -518,7 +518,6 @@ export const EXAMPLES: Record = { icon: '🔎', title: 'getViewProp', screen: GetViewPropExample, - missingOnFabric: true, }, LogExample: { icon: '⌨', diff --git a/packages/react-native-reanimated/src/ReanimatedModule/NativeReanimated.ts b/packages/react-native-reanimated/src/ReanimatedModule/NativeReanimated.ts index 2ead63a541c1..183af679c71a 100644 --- a/packages/react-native-reanimated/src/ReanimatedModule/NativeReanimated.ts +++ b/packages/react-native-reanimated/src/ReanimatedModule/NativeReanimated.ts @@ -13,12 +13,12 @@ import { SHOULD_BE_USE_WEB, } from '../common'; import type { + ComponentWithInstanceMethods, LayoutAnimationBatchItem, ShadowNodeWrapper, StyleProps, Value3D, ValueRotation, - WrapperRef, } from '../commonTypes'; import type { CSSAnimationUpdates, @@ -133,9 +133,8 @@ See https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooti } getViewProp( - viewTag: number, + component: ComponentWithInstanceMethods, propName: string, - component: WrapperRef, // required on Fabric callback?: (result: T) => void ) { const shadowNodeWrapper = getShadowNodeWrapperFromRef(component); diff --git a/packages/react-native-reanimated/src/ReanimatedModule/js-reanimated/JSReanimated.ts b/packages/react-native-reanimated/src/ReanimatedModule/js-reanimated/JSReanimated.ts index e80d11970eef..67f8f4b05c38 100644 --- a/packages/react-native-reanimated/src/ReanimatedModule/js-reanimated/JSReanimated.ts +++ b/packages/react-native-reanimated/src/ReanimatedModule/js-reanimated/JSReanimated.ts @@ -14,11 +14,11 @@ import { ReanimatedError, } from '../../common'; import type { + ComponentWithInstanceMethods, ShadowNodeWrapper, StyleProps, Value3D, ValueRotation, - WrapperRef, } from '../../commonTypes'; import { SensorType } from '../../commonTypes'; import type { @@ -253,9 +253,8 @@ class JSReanimated implements IReanimatedModule { } getViewProp( - _viewTag: number, + _component: ComponentWithInstanceMethods, _propName: string, - _component?: WrapperRef | null, _callback?: (result: T) => void ): Promise { throw new ReanimatedError('getViewProp is not available in JSReanimated.'); diff --git a/packages/react-native-reanimated/src/ReanimatedModule/reanimatedModuleProxy.ts b/packages/react-native-reanimated/src/ReanimatedModule/reanimatedModuleProxy.ts index 2f40a65f1c62..a34fdf159b53 100644 --- a/packages/react-native-reanimated/src/ReanimatedModule/reanimatedModuleProxy.ts +++ b/packages/react-native-reanimated/src/ReanimatedModule/reanimatedModuleProxy.ts @@ -3,12 +3,12 @@ import type { SerializableRef, WorkletFunction } from 'react-native-worklets'; import type { + ComponentWithInstanceMethods, LayoutAnimationBatchItem, ShadowNodeWrapper, StyleProps, Value3D, ValueRotation, - WrapperRef, } from '../commonTypes'; import type { CSSAnimationUpdates, @@ -93,9 +93,8 @@ export interface ReanimatedModuleProxy { export interface IReanimatedModule extends Omit { getViewProp( - viewTag: number, + component: ComponentWithInstanceMethods | null, propName: string, - component: WrapperRef | null, callback?: (result: TValue) => void ): Promise; } diff --git a/packages/react-native-reanimated/src/commonTypes.ts b/packages/react-native-reanimated/src/commonTypes.ts index b848b01fa9f2..53715da73497 100644 --- a/packages/react-native-reanimated/src/commonTypes.ts +++ b/packages/react-native-reanimated/src/commonTypes.ts @@ -465,4 +465,6 @@ type InstanceMethods = { __internalInstanceHandle?: AnyRecord; }; -export type WrapperRef = (React.Component & InstanceMethods) | InstanceMethods; +export type ComponentWithInstanceMethods = + | (React.Component & InstanceMethods) + | InstanceMethods; diff --git a/packages/react-native-reanimated/src/core.ts b/packages/react-native-reanimated/src/core.ts index f922dbe4f20b..1a81bd7c1cae 100644 --- a/packages/react-native-reanimated/src/core.ts +++ b/packages/react-native-reanimated/src/core.ts @@ -9,13 +9,13 @@ import { createSerializable } from 'react-native-worklets'; import { logger, ReanimatedError } from './common'; import type { AnimatedKeyboardOptions, + ComponentWithInstanceMethods, LayoutAnimationBatchItem, SensorConfig, SensorType, SharedValue, Value3D, ValueRotation, - WrapperRef, } from './commonTypes'; import { ReanimatedModule } from './ReanimatedModule'; import { SensorContainer } from './SensorContainer'; @@ -46,35 +46,37 @@ export const isReanimated3 = () => { */ export const isConfigured = isReanimated3; -export function getViewProp( - viewTag: number, - propName: string, - component?: WrapperRef | null // required on Fabric +export function getViewPropImpl( + component: ComponentWithInstanceMethods | null, + propName: string ): Promise { if (!component) { throw new ReanimatedError( - 'Function `getViewProp` requires a component to be passed as an argument on Fabric.' + 'Function `getViewProp` requires a component to be passed as an argument.' ); } // eslint-disable-next-line @typescript-eslint/no-misused-promises return new Promise((resolve, reject) => { - return ReanimatedModule.getViewProp( - viewTag, - propName, - component, - (result: T) => { - if (typeof result === 'string' && result.slice(0, 6) === 'error:') { - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors - reject(result); - } else { - resolve(result); - } + return ReanimatedModule.getViewProp(component, propName, (result: T) => { + if (typeof result === 'string' && result.slice(0, 6) === 'error:') { + // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors + reject(result); + } else { + resolve(result); } - ); + }); }); } +export function getViewProp( + _viewTag: number, + propName: string, + component: ComponentWithInstanceMethods | null +): Promise { + return getViewPropImpl(component, propName); +} + function getSensorContainer(): SensorContainer { if (!global.__sensorContainer) { global.__sensorContainer = new SensorContainer(); diff --git a/packages/react-native-reanimated/src/css/component/AnimatedComponent.tsx b/packages/react-native-reanimated/src/css/component/AnimatedComponent.tsx index db17340db578..059dc4b6474c 100644 --- a/packages/react-native-reanimated/src/css/component/AnimatedComponent.tsx +++ b/packages/react-native-reanimated/src/css/component/AnimatedComponent.tsx @@ -5,7 +5,10 @@ import type { StyleProp } from 'react-native'; import { Platform, StyleSheet } from 'react-native'; import { IS_JEST, ReanimatedError, SHOULD_BE_USE_WEB } from '../../common'; -import type { ShadowNodeWrapper, WrapperRef } from '../../commonTypes'; +import type { + ComponentWithInstanceMethods, + ShadowNodeWrapper, +} from '../../commonTypes'; import type { AnimatedComponentRef, IAnimatedComponentInternalBase, @@ -91,7 +94,7 @@ export default class AnimatedComponent< viewTag = viewInfo.viewTag ?? -1; viewName = viewInfo.viewName; shadowNodeWrapper = getShadowNodeWrapperFromRef( - this as WrapperRef, + this as ComponentWithInstanceMethods, hostInstance ); } diff --git a/packages/react-native-reanimated/src/fabricUtils.ts b/packages/react-native-reanimated/src/fabricUtils.ts index 366174794ec0..e9e6b694d52f 100644 --- a/packages/react-native-reanimated/src/fabricUtils.ts +++ b/packages/react-native-reanimated/src/fabricUtils.ts @@ -1,6 +1,9 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ 'use strict'; -import type { ShadowNodeWrapper, WrapperRef } from './commonTypes'; +import type { + ComponentWithInstanceMethods, + ShadowNodeWrapper, +} from './commonTypes'; import type { HostInstance } from './platform-specific/findHostInstance'; import { findHostInstance } from './platform-specific/findHostInstance'; @@ -9,7 +12,7 @@ let getInternalInstanceHandleFromPublicInstance: (ref: unknown) => { }; export function getShadowNodeWrapperFromRef( - ref: WrapperRef, + component: ComponentWithInstanceMethods, hostInstance?: HostInstance ): ShadowNodeWrapper { if (getInternalInstanceHandleFromPublicInstance === undefined) { @@ -25,15 +28,15 @@ export function getShadowNodeWrapperFromRef( } } - const resolvedRef = - ref.getScrollResponder?.()?.getNativeScrollRef?.() ?? - ref.getNativeScrollRef?.() ?? - ref; + const resolvedComponent = + component.getScrollResponder?.()?.getNativeScrollRef?.() ?? + component.getNativeScrollRef?.() ?? + component; const resolvedInstance = - ref?.__internalInstanceHandle ?? + component?.__internalInstanceHandle ?? getInternalInstanceHandleFromPublicInstance( - hostInstance ?? findHostInstance(resolvedRef) + hostInstance ?? findHostInstance(resolvedComponent) ); return resolvedInstance?.stateNode?.node; diff --git a/packages/react-native-reanimated/src/hook/commonTypes.ts b/packages/react-native-reanimated/src/hook/commonTypes.ts index bfe7d414403e..72fcd0b8bf29 100644 --- a/packages/react-native-reanimated/src/hook/commonTypes.ts +++ b/packages/react-native-reanimated/src/hook/commonTypes.ts @@ -12,8 +12,8 @@ import type { WorkletFunction } from 'react-native-worklets'; import type { AnimatedPropsAdapterFunction, AnimatedStyle, + ComponentWithInstanceMethods, ShadowNodeWrapper, - WrapperRef, } from '../commonTypes'; import type { AnimatedProps } from '../createAnimatedComponent/commonTypes'; import type { ReanimatedHTMLElement } from '../ReanimatedModule/js-reanimated'; @@ -30,17 +30,18 @@ export type MaybeObserverCleanup = (() => void) | undefined; export type AnimatedRefObserver = (tag: number | null) => MaybeObserverCleanup; -export type AnimatedRef = { - (ref?: TRef | null): +export type AnimatedRef = { + (ref?: TComponent | null): | ShadowNodeWrapper // Native | HTMLElement; // web - current: TRef | null; + current: TComponent | null; observe: (observer: AnimatedRefObserver) => void; + getViewProp: (propName: string) => Promise; getTag?: () => number | null; }; // Might make that type generic if it's ever needed. -export type AnimatedRefOnJS = AnimatedRef; +export type AnimatedRefOnJS = AnimatedRef; /** * `AnimatedRef` is mapped to this type on the UI thread via a serializable diff --git a/packages/react-native-reanimated/src/hook/useAnimatedRef.ts b/packages/react-native-reanimated/src/hook/useAnimatedRef.ts index ad903a60f425..0d99cc61aeeb 100644 --- a/packages/react-native-reanimated/src/hook/useAnimatedRef.ts +++ b/packages/react-native-reanimated/src/hook/useAnimatedRef.ts @@ -6,7 +6,11 @@ import { } from 'react-native-worklets'; import { SHOULD_BE_USE_WEB } from '../common/constants'; -import type { ShadowNodeWrapper, WrapperRef } from '../commonTypes'; +import type { + ComponentWithInstanceMethods, + ShadowNodeWrapper, +} from '../commonTypes'; +import { getViewPropImpl } from '../core'; import { getShadowNodeWrapperFromRef } from '../fabricUtils'; import { makeMutable } from '../mutables'; import { findNodeHandle } from '../platformFunctions/findNodeHandle'; @@ -17,27 +21,31 @@ import type { MaybeObserverCleanup, } from './commonTypes'; -function getComponentOrScrollable(ref: WrapperRef) { - return ref.getNativeScrollRef?.() ?? ref.getScrollableNode?.() ?? ref; +function getComponentOrScrollable(component: ComponentWithInstanceMethods) { + return ( + component.getNativeScrollRef?.() ?? + component.getScrollableNode?.() ?? + component + ); } -function useAnimatedRefBase( - getWrapper: (ref: TRef) => ShadowNodeWrapper -): AnimatedRef { +function useAnimatedRefBase( + getWrapper: (component: TComponent) => ShadowNodeWrapper +): AnimatedRef { const observers = useRef>( new Map() ).current; - const wrapperRef = useRef(null); - const resultRef = useRef | null>(null); + const shadowNodeWrapperRef = useRef(null); + const resultRef = useRef | null>(null); if (!resultRef.current) { - const fun = >((ref) => { - if (ref) { - wrapperRef.current = getWrapper(ref); + const fun = >((component) => { + if (component) { + shadowNodeWrapperRef.current = getWrapper(component); // We have to unwrap the tag from the shadow node wrapper. - fun.getTag = () => findNodeHandle(getComponentOrScrollable(ref)); - fun.current = ref; + fun.getTag = () => findNodeHandle(getComponentOrScrollable(component)); + fun.current = component; if (observers.size) { const currentTag = fun?.getTag?.() ?? null; @@ -52,7 +60,7 @@ function useAnimatedRefBase( } } - return wrapperRef.current; + return shadowNodeWrapperRef.current; }); fun.observe = (observer: AnimatedRefObserver) => { @@ -66,6 +74,9 @@ function useAnimatedRefBase( }; }; + fun.getViewProp = (propName: string) => + getViewPropImpl(fun.current, propName); + fun.current = null; resultRef.current = fun; } @@ -74,15 +85,15 @@ function useAnimatedRefBase( } function useAnimatedRefNative< - TRef extends WrapperRef = React.Component, ->(): AnimatedRef { + TComponent extends ComponentWithInstanceMethods = React.Component, +>(): AnimatedRef { const [sharedWrapper] = useState(() => makeMutable(null) ); - const resultRef = useAnimatedRefBase((ref) => { + const resultRef = useAnimatedRefBase((component) => { const currentWrapper = getShadowNodeWrapperFromRef( - getComponentOrScrollable(ref) + getComponentOrScrollable(component) ); sharedWrapper.value = currentWrapper; @@ -104,9 +115,11 @@ function useAnimatedRefNative< } function useAnimatedRefWeb< - TRef extends WrapperRef = React.Component, ->(): AnimatedRef { - return useAnimatedRefBase((ref) => getComponentOrScrollable(ref)); + TComponent extends ComponentWithInstanceMethods = React.Component, +>(): AnimatedRef { + return useAnimatedRefBase((component) => + getComponentOrScrollable(component) + ); } /** diff --git a/packages/react-native-reanimated/src/hook/useScrollOffset.ts b/packages/react-native-reanimated/src/hook/useScrollOffset.ts index f9518a47813e..fe8619d09835 100644 --- a/packages/react-native-reanimated/src/hook/useScrollOffset.ts +++ b/packages/react-native-reanimated/src/hook/useScrollOffset.ts @@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef } from 'react'; import { IS_WEB, logger } from '../common'; -import type { SharedValue, WrapperRef } from '../commonTypes'; +import type { ComponentWithInstanceMethods, SharedValue } from '../commonTypes'; import type { AnimatedRef, ReanimatedScrollEvent, @@ -37,8 +37,8 @@ export const useScrollOffset = IS_WEB ? useScrollOffsetWeb : useScrollOffsetNative; -function useScrollOffsetWeb( - animatedRef: AnimatedRef | null, +function useScrollOffsetWeb( + animatedRef: AnimatedRef | null, providedOffset?: SharedValue ): SharedValue { const internalOffset = useSharedValue(0); @@ -77,8 +77,8 @@ function useScrollOffsetWeb( return offset; } -function useScrollOffsetNative( - animatedRef: AnimatedRef | null, +function useScrollOffsetNative( + animatedRef: AnimatedRef | null, providedOffset?: SharedValue ): SharedValue { const internalOffset = useSharedValue(0); @@ -118,6 +118,8 @@ function useScrollOffsetNative( return offset; } -function getWebScrollableElement(scrollComponent: WrapperRef): HTMLElement { - return scrollComponent?.getScrollableNode?.() ?? scrollComponent; +function getWebScrollableElement( + component: ComponentWithInstanceMethods +): HTMLElement { + return component?.getScrollableNode?.() ?? component; } diff --git a/packages/react-native-reanimated/src/platform-specific/findHostInstance.ts b/packages/react-native-reanimated/src/platform-specific/findHostInstance.ts index f2c53b34879a..ed058c8a256b 100644 --- a/packages/react-native-reanimated/src/platform-specific/findHostInstance.ts +++ b/packages/react-native-reanimated/src/platform-specific/findHostInstance.ts @@ -2,7 +2,7 @@ 'use strict'; import { ReanimatedError } from '../common'; -import type { WrapperRef } from '../commonTypes'; +import type { ComponentWithInstanceMethods } from '../commonTypes'; import type { IAnimatedComponentInternalBase } from '../createAnimatedComponent/commonTypes'; export type HostInstance = { @@ -46,11 +46,11 @@ function resolveFindHostInstance_DEPRECATED() { let findHostInstance_DEPRECATED: (ref: unknown) => HostInstance; export function findHostInstance( - ref: IAnimatedComponentInternalBase | WrapperRef + component: IAnimatedComponentInternalBase | ComponentWithInstanceMethods ): HostInstance { // Fast path for native refs const hostInstance = findHostInstanceFastPath( - (ref as IAnimatedComponentInternalBase)._componentRef as HostInstance + (component as IAnimatedComponentInternalBase)._componentRef as HostInstance ); if (hostInstance !== undefined) { return hostInstance; @@ -64,8 +64,8 @@ export function findHostInstance( a valid React ref. */ return findHostInstance_DEPRECATED( - (ref as IAnimatedComponentInternalBase)._hasAnimatedRef - ? (ref as IAnimatedComponentInternalBase)._componentRef - : ref + (component as IAnimatedComponentInternalBase)._hasAnimatedRef + ? (component as IAnimatedComponentInternalBase)._componentRef + : component ); } diff --git a/packages/react-native-reanimated/src/platformFunctions/dispatchCommand.ts b/packages/react-native-reanimated/src/platformFunctions/dispatchCommand.ts index 6f00a5c96b1f..b257b79bf76a 100644 --- a/packages/react-native-reanimated/src/platformFunctions/dispatchCommand.ts +++ b/packages/react-native-reanimated/src/platformFunctions/dispatchCommand.ts @@ -2,15 +2,18 @@ import { RuntimeKind } from 'react-native-worklets'; import { IS_JEST, logger, SHOULD_BE_USE_WEB } from '../common'; -import type { ShadowNodeWrapper, WrapperRef } from '../commonTypes'; +import type { + ComponentWithInstanceMethods, + ShadowNodeWrapper, +} from '../commonTypes'; import type { AnimatedRef, AnimatedRefOnJS, AnimatedRefOnUI, } from '../hook/commonTypes'; -type DispatchCommand = ( - animatedRef: AnimatedRef, +type DispatchCommand = ( + animatedRef: AnimatedRef, commandName: string, args?: unknown[] ) => void; diff --git a/packages/react-native-reanimated/src/platformFunctions/getRelativeCoords.ts b/packages/react-native-reanimated/src/platformFunctions/getRelativeCoords.ts index 417278412944..4b235fac2c0f 100644 --- a/packages/react-native-reanimated/src/platformFunctions/getRelativeCoords.ts +++ b/packages/react-native-reanimated/src/platformFunctions/getRelativeCoords.ts @@ -1,5 +1,5 @@ 'use strict'; -import type { WrapperRef } from '../commonTypes'; +import type { ComponentWithInstanceMethods } from '../commonTypes'; import type { AnimatedRef } from '../hook/commonTypes'; import { measure } from './measure'; @@ -21,8 +21,10 @@ export interface ComponentCoords { * {@link ComponentCoords}. * @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/getRelativeCoords */ -export function getRelativeCoords( - animatedRef: AnimatedRef, +export function getRelativeCoords< + TComponent extends ComponentWithInstanceMethods, +>( + animatedRef: AnimatedRef, absoluteX: number, absoluteY: number ): ComponentCoords | null { diff --git a/packages/react-native-reanimated/src/platformFunctions/measure.ts b/packages/react-native-reanimated/src/platformFunctions/measure.ts index e8bf15885d1a..74c5298f4ea5 100644 --- a/packages/react-native-reanimated/src/platformFunctions/measure.ts +++ b/packages/react-native-reanimated/src/platformFunctions/measure.ts @@ -3,9 +3,9 @@ import { RuntimeKind } from 'react-native-worklets'; import { IS_JEST, logger, SHOULD_BE_USE_WEB } from '../common'; import type { + ComponentWithInstanceMethods, MeasuredDimensions, ShadowNodeWrapper, - WrapperRef, } from '../commonTypes'; import type { AnimatedRef, @@ -13,8 +13,8 @@ import type { AnimatedRefOnUI, } from '../hook/commonTypes'; -type Measure = ( - animatedRef: AnimatedRef +type Measure = ( + animatedRef: AnimatedRef ) => MeasuredDimensions | null; /** diff --git a/packages/react-native-reanimated/src/platformFunctions/measure.web.ts b/packages/react-native-reanimated/src/platformFunctions/measure.web.ts index 859e7de763a4..bcd92de4d78c 100644 --- a/packages/react-native-reanimated/src/platformFunctions/measure.web.ts +++ b/packages/react-native-reanimated/src/platformFunctions/measure.web.ts @@ -1,10 +1,13 @@ 'use strict'; import { logger } from '../common'; -import type { MeasuredDimensions, WrapperRef } from '../commonTypes'; +import type { + ComponentWithInstanceMethods, + MeasuredDimensions, +} from '../commonTypes'; import type { AnimatedRef } from '../hook/commonTypes'; -export function measure( - animatedRef: AnimatedRef +export function measure( + animatedRef: AnimatedRef ): MeasuredDimensions | null { const element = animatedRef() as HTMLElement | null; diff --git a/packages/react-native-reanimated/src/platformFunctions/scrollTo.ts b/packages/react-native-reanimated/src/platformFunctions/scrollTo.ts index fd0ad4fc7a3e..ef9d6dcb98c6 100644 --- a/packages/react-native-reanimated/src/platformFunctions/scrollTo.ts +++ b/packages/react-native-reanimated/src/platformFunctions/scrollTo.ts @@ -1,11 +1,11 @@ 'use strict'; import { IS_JEST, logger, SHOULD_BE_USE_WEB } from '../common'; -import type { WrapperRef } from '../commonTypes'; +import type { ComponentWithInstanceMethods } from '../commonTypes'; import type { AnimatedRef } from '../hook/commonTypes'; import { dispatchCommand } from './dispatchCommand'; -type ScrollTo = ( - animatedRef: AnimatedRef, +type ScrollTo = ( + animatedRef: AnimatedRef, x: number, y: number, animated: boolean @@ -24,8 +24,8 @@ type ScrollTo = ( */ export let scrollTo: ScrollTo; -function scrollToNative( - animatedRef: AnimatedRef, +function scrollToNative( + animatedRef: AnimatedRef, x: number, y: number, animated: boolean diff --git a/packages/react-native-reanimated/src/platformFunctions/scrollTo.web.ts b/packages/react-native-reanimated/src/platformFunctions/scrollTo.web.ts index 7413149dc9d7..6ad23f5c8838 100644 --- a/packages/react-native-reanimated/src/platformFunctions/scrollTo.web.ts +++ b/packages/react-native-reanimated/src/platformFunctions/scrollTo.web.ts @@ -1,11 +1,11 @@ 'use strict'; import type { ScrollView } from 'react-native'; -import type { WrapperRef } from '../commonTypes'; +import type { ComponentWithInstanceMethods } from '../commonTypes'; import type { AnimatedRef } from '../hook/commonTypes'; -export function scrollTo( - animatedRef: AnimatedRef, +export function scrollTo( + animatedRef: AnimatedRef, x: number, y: number, animated: boolean diff --git a/packages/react-native-reanimated/src/platformFunctions/setNativeProps.ts b/packages/react-native-reanimated/src/platformFunctions/setNativeProps.ts index 9cbcc0e3e7fb..61c478bfdaf9 100644 --- a/packages/react-native-reanimated/src/platformFunctions/setNativeProps.ts +++ b/packages/react-native-reanimated/src/platformFunctions/setNativeProps.ts @@ -7,15 +7,19 @@ import { processColorsInProps, SHOULD_BE_USE_WEB, } from '../common'; -import type { ShadowNodeWrapper, StyleProps, WrapperRef } from '../commonTypes'; +import type { + ComponentWithInstanceMethods, + ShadowNodeWrapper, + StyleProps, +} from '../commonTypes'; import type { AnimatedRef, AnimatedRefOnJS, AnimatedRefOnUI, } from '../hook/commonTypes'; -type SetNativeProps = ( - animatedRef: AnimatedRef, +type SetNativeProps = ( + animatedRef: AnimatedRef, updates: StyleProps ) => void; /** diff --git a/packages/react-native-reanimated/src/platformFunctions/setNativeProps.web.ts b/packages/react-native-reanimated/src/platformFunctions/setNativeProps.web.ts index 82d323c05422..5c545005b6e9 100644 --- a/packages/react-native-reanimated/src/platformFunctions/setNativeProps.web.ts +++ b/packages/react-native-reanimated/src/platformFunctions/setNativeProps.web.ts @@ -1,11 +1,11 @@ 'use strict'; -import type { StyleProps, WrapperRef } from '../commonTypes'; +import type { ComponentWithInstanceMethods, StyleProps } from '../commonTypes'; import type { AnimatedRef } from '../hook/commonTypes'; import type { ReanimatedHTMLElement } from '../ReanimatedModule/js-reanimated'; import { _updatePropsJS } from '../ReanimatedModule/js-reanimated'; -export function setNativeProps( - animatedRef: AnimatedRef, +export function setNativeProps( + animatedRef: AnimatedRef, updates: StyleProps ) { const component = animatedRef() as ReanimatedHTMLElement;