react-native-reanimated 3.16.4 → 3.16.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +21 -13
  2. package/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +2 -0
  3. package/lib/module/createAnimatedComponent/JSPropsUpdater.js +4 -5
  4. package/lib/module/createAnimatedComponent/JSPropsUpdater.js.map +1 -1
  5. package/lib/module/createAnimatedComponent/NativeEventsManager.js +35 -8
  6. package/lib/module/createAnimatedComponent/NativeEventsManager.js.map +1 -1
  7. package/lib/module/createAnimatedComponent/createAnimatedComponent.js +51 -46
  8. package/lib/module/createAnimatedComponent/createAnimatedComponent.js.map +1 -1
  9. package/lib/module/fabricUtils.js +4 -11
  10. package/lib/module/fabricUtils.js.map +1 -1
  11. package/lib/module/platform-specific/findHostInstance.js +44 -0
  12. package/lib/module/platform-specific/findHostInstance.js.map +1 -0
  13. package/lib/module/platform-specific/findHostInstance.web.js +4 -0
  14. package/lib/module/platform-specific/findHostInstance.web.js.map +1 -0
  15. package/lib/module/platform-specific/jsVersion.js +1 -1
  16. package/lib/typescript/createAnimatedComponent/JSPropsUpdater.d.ts.map +1 -1
  17. package/lib/typescript/createAnimatedComponent/NativeEventsManager.d.ts.map +1 -1
  18. package/lib/typescript/createAnimatedComponent/commonTypes.d.ts +6 -6
  19. package/lib/typescript/createAnimatedComponent/commonTypes.d.ts.map +1 -1
  20. package/lib/typescript/createAnimatedComponent/createAnimatedComponent.d.ts.map +1 -1
  21. package/lib/typescript/fabricUtils.d.ts +2 -1
  22. package/lib/typescript/fabricUtils.d.ts.map +1 -1
  23. package/lib/typescript/platform-specific/findHostInstance.d.ts +15 -0
  24. package/lib/typescript/platform-specific/findHostInstance.d.ts.map +1 -0
  25. package/lib/typescript/platform-specific/findHostInstance.web.d.ts +2 -0
  26. package/lib/typescript/platform-specific/findHostInstance.web.d.ts.map +1 -0
  27. package/lib/typescript/platform-specific/jsVersion.d.ts +1 -1
  28. package/package.json +1 -1
  29. package/src/createAnimatedComponent/JSPropsUpdater.ts +4 -5
  30. package/src/createAnimatedComponent/NativeEventsManager.ts +44 -13
  31. package/src/createAnimatedComponent/commonTypes.ts +6 -6
  32. package/src/createAnimatedComponent/createAnimatedComponent.tsx +55 -56
  33. package/src/fabricUtils.ts +9 -15
  34. package/src/platform-specific/findHostInstance.ts +77 -0
  35. package/src/platform-specific/findHostInstance.web.ts +3 -0
  36. package/src/platform-specific/jsVersion.ts +1 -1
  37. package/lib/module/platform-specific/RNRenderer.js +0 -6
  38. package/lib/module/platform-specific/RNRenderer.js.map +0 -1
  39. package/lib/module/platform-specific/RNRenderer.web.js +0 -6
  40. package/lib/module/platform-specific/RNRenderer.web.js.map +0 -1
  41. package/lib/typescript/platform-specific/RNRenderer.d.ts +0 -2
  42. package/lib/typescript/platform-specific/RNRenderer.d.ts.map +0 -1
  43. package/lib/typescript/platform-specific/RNRenderer.web.d.ts +0 -3
  44. package/lib/typescript/platform-specific/RNRenderer.web.d.ts.map +0 -1
  45. package/src/platform-specific/RNRenderer.ts +0 -4
  46. package/src/platform-specific/RNRenderer.web.ts +0 -4
@@ -0,0 +1 @@
1
+ {"version":3,"names":["findHostInstance","_component"],"sourceRoot":"../../../src","sources":["platform-specific/findHostInstance.web.ts"],"mappings":"AAAA,YAAY;;AAEZ,OAAO,SAASA,gBAAgBA,CAACC,UAAe,EAAQ,CAAC","ignoreList":[]}
@@ -5,5 +5,5 @@
5
5
  * version used to build the native part of the library in runtime. Remember to
6
6
  * keep this in sync with the version declared in `package.json`
7
7
  */
8
- export const jsVersion = '3.16.4';
8
+ export const jsVersion = '3.16.6';
9
9
  //# sourceMappingURL=jsVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"JSPropsUpdater.d.ts","sourceRoot":"","sources":["../../../src/createAnimatedComponent/JSPropsUpdater.ts"],"names":[],"mappings":";AAOA,OA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,CAAC;AAS1C,eAAe,cAAc,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"NativeEventsManager.d.ts","sourceRoot":"","sources":["../../../src/createAnimatedComponent/NativeEventsManager.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,eAAe,CAAC;AAKvB,qBAAa,mBAAoB,YAAW,oBAAoB;;gBAKlD,SAAS,EAAE,wBAAwB,EAAE,OAAO,CAAC,EAAE,gBAAgB;IAMpE,YAAY;IAMZ,YAAY;IASZ,YAAY,CACjB,SAAS,EAAE,sBAAsB,CAAC,qBAAqB,CAAC;IAwC1D,OAAO,CAAC,eAAe;CAkBxB;AA0BD,KAAK,wBAAwB,GAAG,KAAK,CAAC,SAAS,CAC7C,sBAAsB,CAAC,qBAAqB,CAAC,CAC9C,GACC,0BAA0B,CAAC;AAE7B,KAAK,gBAAgB,GAAG;IACtB,cAAc,EAAE,CACd,GAAG,EAAE,oBAAoB,EACzB,KAAK,EAAE,qBAAqB,KACzB,IAAI,CAAC;CACX,CAAC"}
1
+ {"version":3,"file":"NativeEventsManager.d.ts","sourceRoot":"","sources":["../../../src/createAnimatedComponent/NativeEventsManager.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,eAAe,CAAC;AAKvB,qBAAa,mBAAoB,YAAW,oBAAoB;;gBAKlD,SAAS,EAAE,wBAAwB,EAAE,OAAO,CAAC,EAAE,gBAAgB;IAMpE,YAAY;IAMZ,YAAY;IASZ,YAAY,CACjB,SAAS,EAAE,sBAAsB,CAAC,qBAAqB,CAAC;IAwC1D,OAAO,CAAC,eAAe;CAiDxB;AA0BD,KAAK,wBAAwB,GAAG,KAAK,CAAC,SAAS,CAC7C,sBAAsB,CAAC,qBAAqB,CAAC,CAC9C,GACC,0BAA0B,CAAC;AAE7B,KAAK,gBAAgB,GAAG;IACtB,cAAc,EAAE,CACd,GAAG,EAAE,oBAAoB,EACzB,KAAK,EAAE,qBAAqB,KACzB,IAAI,CAAC;CACX,CAAC"}
@@ -52,17 +52,12 @@ export interface AnimatedComponentRef extends Component {
52
52
  export interface IAnimatedComponentInternal {
53
53
  _styles: StyleProps[] | null;
54
54
  _animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;
55
- /**
56
- * Used for Shared Element Transitions, Layout Animations and Animated Styles.
57
- * It is not related to event handling.
58
- */
59
- _componentViewTag: number;
60
55
  _isFirstRender: boolean;
61
56
  jestInlineStyle: NestedArray<StyleProps> | undefined;
62
57
  jestAnimatedStyle: {
63
58
  value: StyleProps;
64
59
  };
65
- _component: AnimatedComponentRef | HTMLElement | null;
60
+ _componentRef: AnimatedComponentRef | HTMLElement | null;
66
61
  _sharedElementTransition: SharedTransition | null;
67
62
  _jsPropsUpdater: IJSPropsUpdater;
68
63
  _InlinePropManager: IInlinePropManager;
@@ -71,6 +66,11 @@ export interface IAnimatedComponentInternal {
71
66
  _NativeEventsManager?: INativeEventsManager;
72
67
  _viewInfo?: ViewInfo;
73
68
  context: React.ContextType<typeof SkipEnteringContext>;
69
+ /**
70
+ * Used for Shared Element Transitions, Layout Animations and Animated Styles.
71
+ * It is not related to event handling.
72
+ */
73
+ getComponentViewTag: () => number;
74
74
  }
75
75
  export type NestedArray<T> = T | NestedArray<T>[];
76
76
  export interface InitialComponentProps extends Record<string, unknown> {
@@ -1 +1 @@
1
- {"version":3,"file":"commonTypes.d.ts","sourceRoot":"","sources":["../../../src/createAnimatedComponent/commonTypes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EACV,iBAAiB,EACjB,WAAW,EACX,UAAU,EACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,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C,EAAE,MAAM,oBAAoB,CAAC;CAC/C;AAED,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IAC7B,cAAc,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,CAAC;IAChE,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,WAAW,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;IACrD,iBAAiB,EAAE;QAAE,KAAK,EAAE,UAAU,CAAA;KAAE,CAAC;IACzC,aAAa,EAAE,oBAAoB,GAAG,WAAW,GAAG,IAAI,CAAC;IACzD,wBAAwB,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAClD,eAAe,EAAE,eAAe,CAAC;IACjC,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,YAAY,EAAE,YAAY,CAAC;IAC3B,4BAA4B;IAC5B,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,SAAS,CAAC,EAAE,QAAQ,CAAC;IACrB,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,OAAO,mBAAmB,CAAC,CAAC;IACvD;;;OAGG;IACH,mBAAmB,EAAE,MAAM,MAAM,CAAC;CACnC;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;AAElD,MAAM,WAAW,qBAAsB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACpE,GAAG,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"createAnimatedComponent.d.ts","sourceRoot":"","sources":["../../../src/createAnimatedComponent/createAnimatedComponent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,cAAc,EACd,aAAa,EACb,iBAAiB,EAElB,MAAM,OAAO,CAAC;AAIf,OAAO,wCAAwC,CAAC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O,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,GACrB,cAAc,CAAC,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import type { ShadowNodeWrapper } from './commonTypes';
3
- export declare function getShadowNodeWrapperFromRef(ref: React.Component): ShadowNodeWrapper;
3
+ import { HostInstance } from './platform-specific/findHostInstance';
4
+ export declare function getShadowNodeWrapperFromRef(ref: React.Component, hostInstance?: HostInstance): ShadowNodeWrapper;
4
5
  //# sourceMappingURL=fabricUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fabricUtils.d.ts","sourceRoot":"","sources":["../../src/fabricUtils.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAOvD,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,KAAK,CAAC,SAAS,GACnB,iBAAiB,CA6CnB"}
1
+ {"version":3,"file":"fabricUtils.d.ts","sourceRoot":"","sources":["../../src/fabricUtils.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAEL,YAAY,EACb,MAAM,sCAAsC,CAAC;AAM9C,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,KAAK,CAAC,SAAS,EACpB,YAAY,CAAC,EAAE,YAAY,GAC1B,iBAAiB,CAmCnB"}
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ import type { IAnimatedComponentInternal } from '../createAnimatedComponent/commonTypes';
3
+ type HostInstanceFabric = {
4
+ __internalInstanceHandle?: Record<string, unknown>;
5
+ __nativeTag?: number;
6
+ _viewConfig?: Record<string, unknown>;
7
+ };
8
+ type HostInstancePaper = {
9
+ _nativeTag?: number;
10
+ viewConfig?: Record<string, unknown>;
11
+ };
12
+ export type HostInstance = HostInstanceFabric & HostInstancePaper;
13
+ export declare function findHostInstance(component: IAnimatedComponentInternal | React.Component): HostInstance;
14
+ export {};
15
+ //# sourceMappingURL=findHostInstance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findHostInstance.d.ts","sourceRoot":"","sources":["../../../src/platform-specific/findHostInstance.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AAIzF,KAAK,kBAAkB,GAAG;IACxB,wBAAwB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,kBAAkB,GAAG,iBAAiB,CAAC;AAwClE,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,0BAA0B,GAAG,KAAK,CAAC,SAAS,GACtD,YAAY,CAgBd"}
@@ -0,0 +1,2 @@
1
+ export declare function findHostInstance(_component: any): void;
2
+ //# sourceMappingURL=findHostInstance.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findHostInstance.web.d.ts","sourceRoot":"","sources":["../../../src/platform-specific/findHostInstance.web.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,GAAG,GAAG,IAAI,CAAG"}
@@ -3,5 +3,5 @@
3
3
  * version used to build the native part of the library in runtime. Remember to
4
4
  * keep this in sync with the version declared in `package.json`
5
5
  */
6
- export declare const jsVersion = "3.16.4";
6
+ export declare const jsVersion = "3.16.6";
7
7
  //# sourceMappingURL=jsVersion.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-reanimated",
3
- "version": "3.16.4",
3
+ "version": "3.16.6",
4
4
  "description": "More powerful alternative to Animated library for React Native.",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
  import { NativeEventEmitter, Platform } from 'react-native';
3
- import { findNodeHandle } from '../platformFunctions/findNodeHandle';
4
3
  import type { NativeModule } from 'react-native';
5
4
  import { shouldBeUseWeb } from '../PlatformChecker';
6
5
  import type { StyleProps } from '../commonTypes';
@@ -39,7 +38,7 @@ class JSPropsUpdaterPaper implements IJSPropsUpdater {
39
38
  > &
40
39
  IAnimatedComponentInternal
41
40
  ) {
42
- const viewTag = findNodeHandle(animatedComponent);
41
+ const viewTag = animatedComponent.getComponentViewTag();
43
42
  JSPropsUpdaterPaper._tagToComponentMapping.set(viewTag, animatedComponent);
44
43
  if (JSPropsUpdaterPaper._tagToComponentMapping.size === 1) {
45
44
  const listener = (data: ListenerData) => {
@@ -61,7 +60,7 @@ class JSPropsUpdaterPaper implements IJSPropsUpdater {
61
60
  > &
62
61
  IAnimatedComponentInternal
63
62
  ) {
64
- const viewTag = findNodeHandle(animatedComponent);
63
+ const viewTag = animatedComponent.getComponentViewTag();
65
64
  JSPropsUpdaterPaper._tagToComponentMapping.delete(viewTag);
66
65
  if (JSPropsUpdaterPaper._tagToComponentMapping.size === 0) {
67
66
  this._reanimatedEventEmitter.removeAllListeners(
@@ -101,7 +100,7 @@ class JSPropsUpdaterFabric implements IJSPropsUpdater {
101
100
  if (!JSPropsUpdaterFabric.isInitialized) {
102
101
  return;
103
102
  }
104
- const viewTag = findNodeHandle(animatedComponent);
103
+ const viewTag = animatedComponent.getComponentViewTag();
105
104
  JSPropsUpdaterFabric._tagToComponentMapping.set(viewTag, animatedComponent);
106
105
  }
107
106
 
@@ -114,7 +113,7 @@ class JSPropsUpdaterFabric implements IJSPropsUpdater {
114
113
  if (!JSPropsUpdaterFabric.isInitialized) {
115
114
  return;
116
115
  }
117
- const viewTag = findNodeHandle(animatedComponent);
116
+ const viewTag = animatedComponent.getComponentViewTag();
118
117
  JSPropsUpdaterFabric._tagToComponentMapping.delete(viewTag);
119
118
  }
120
119
  }
@@ -39,7 +39,7 @@ export class NativeEventsManager implements INativeEventsManager {
39
39
  public updateEvents(
40
40
  prevProps: AnimatedComponentProps<InitialComponentProps>
41
41
  ) {
42
- const computedEventTag = this.getEventViewTag();
42
+ const computedEventTag = this.getEventViewTag(true);
43
43
  // If the event view tag changes, we need to completely re-mount all events
44
44
  if (this.#eventViewTag !== computedEventTag) {
45
45
  // Remove all bindings from previous props that ran on the old viewTag
@@ -77,23 +77,54 @@ export class NativeEventsManager implements INativeEventsManager {
77
77
  });
78
78
  }
79
79
 
80
- private getEventViewTag() {
80
+ private getEventViewTag(componentUpdate: boolean = false) {
81
81
  // Get the tag for registering events - since the event emitting view can be nested inside the main component
82
82
  const componentAnimatedRef = this.#managedComponent
83
- ._component as AnimatedComponentRef;
84
- let newTag: number;
83
+ ._componentRef as AnimatedComponentRef & {
84
+ // Fabric
85
+ __nativeTag?: number;
86
+ // Paper
87
+ _nativeTag?: number;
88
+ };
85
89
  if (componentAnimatedRef.getScrollableNode) {
90
+ /*
91
+ In most cases, getScrollableNode() returns a view tag, and findNodeHandle is not required.
92
+ However, to cover more exotic list cases, we will continue to use findNodeHandle
93
+ for consistency. For numerical values, findNodeHandle should return the value immediately,
94
+ as documented here: https://github.com/facebook/react/blob/91061073d57783c061889ac6720ef1ab7f0c2149/packages/react-native-renderer/src/ReactNativePublicCompat.js#L113
95
+ */
86
96
  const scrollableNode = componentAnimatedRef.getScrollableNode();
87
- newTag = findNodeHandle(scrollableNode) ?? -1;
88
- } else {
89
- newTag =
90
- findNodeHandle(
91
- this.#componentOptions?.setNativeProps
92
- ? this.#managedComponent
93
- : componentAnimatedRef
94
- ) ?? -1;
97
+ if (typeof scrollableNode === 'number') {
98
+ return scrollableNode;
99
+ }
100
+ return findNodeHandle(scrollableNode) ?? -1;
101
+ }
102
+ if (this.#componentOptions?.setNativeProps) {
103
+ // This case ensures backward compatibility with components that
104
+ // have their own setNativeProps method passed as an option.
105
+ return findNodeHandle(this.#managedComponent) ?? -1;
106
+ }
107
+ if (!componentUpdate) {
108
+ // On the first render of a component, we may already receive a resolved view tag.
109
+ return this.#managedComponent.getComponentViewTag();
110
+ }
111
+ if (componentAnimatedRef.__nativeTag || componentAnimatedRef._nativeTag) {
112
+ /*
113
+ Fast path for native refs,
114
+ _nativeTag is used by Paper components,
115
+ __nativeTag is used by Fabric components.
116
+ */
117
+ return (
118
+ componentAnimatedRef.__nativeTag ??
119
+ componentAnimatedRef._nativeTag ??
120
+ -1
121
+ );
95
122
  }
96
- return newTag;
123
+ /*
124
+ When a component is updated, a child could potentially change and have a different
125
+ view tag. This can occur with a GestureDetector component.
126
+ */
127
+ return findNodeHandle(componentAnimatedRef) ?? -1;
97
128
  }
98
129
  }
99
130
 
@@ -100,15 +100,10 @@ export interface AnimatedComponentRef extends Component {
100
100
  export interface IAnimatedComponentInternal {
101
101
  _styles: StyleProps[] | null;
102
102
  _animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;
103
- /**
104
- * Used for Shared Element Transitions, Layout Animations and Animated Styles.
105
- * It is not related to event handling.
106
- */
107
- _componentViewTag: number;
108
103
  _isFirstRender: boolean;
109
104
  jestInlineStyle: NestedArray<StyleProps> | undefined;
110
105
  jestAnimatedStyle: { value: StyleProps };
111
- _component: AnimatedComponentRef | HTMLElement | null;
106
+ _componentRef: AnimatedComponentRef | HTMLElement | null;
112
107
  _sharedElementTransition: SharedTransition | null;
113
108
  _jsPropsUpdater: IJSPropsUpdater;
114
109
  _InlinePropManager: IInlinePropManager;
@@ -117,6 +112,11 @@ export interface IAnimatedComponentInternal {
117
112
  _NativeEventsManager?: INativeEventsManager;
118
113
  _viewInfo?: ViewInfo;
119
114
  context: React.ContextType<typeof SkipEnteringContext>;
115
+ /**
116
+ * Used for Shared Element Transitions, Layout Animations and Animated Styles.
117
+ * It is not related to event handling.
118
+ */
119
+ getComponentViewTag: () => number;
120
120
  }
121
121
 
122
122
  export type NestedArray<T> = T | NestedArray<T>[];
@@ -8,11 +8,10 @@ import type {
8
8
  } from 'react';
9
9
  import React from 'react';
10
10
  import { Platform } from 'react-native';
11
- import { findNodeHandle } from '../platformFunctions/findNodeHandle';
12
11
  import '../layoutReanimation/animationsManager';
13
12
  import invariant from 'invariant';
14
13
  import { adaptViewConfig } from '../ConfigHelper';
15
- import { RNRenderer } from '../platform-specific/RNRenderer';
14
+ import { findHostInstance } from '../platform-specific/findHostInstance';
16
15
  import { enableLayoutAnimations } from '../core';
17
16
  import { SharedTransition, LayoutAnimationType } from '../layoutReanimation';
18
17
  import type { StyleProps, ShadowNodeWrapper } from '../commonTypes';
@@ -124,11 +123,10 @@ export function createAnimatedComponent(
124
123
  {
125
124
  _styles: StyleProps[] | null = null;
126
125
  _animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;
127
- _componentViewTag = -1;
128
126
  _isFirstRender = true;
129
127
  jestInlineStyle: NestedArray<StyleProps> | undefined;
130
128
  jestAnimatedStyle: { value: StyleProps } = { value: {} };
131
- _component: AnimatedComponentRef | HTMLElement | null = null;
129
+ _componentRef: AnimatedComponentRef | HTMLElement | null = null;
132
130
  _sharedElementTransition: SharedTransition | null = null;
133
131
  _jsPropsUpdater = new JSPropsUpdater();
134
132
  _InlinePropManager = new InlinePropManager();
@@ -156,7 +154,6 @@ export function createAnimatedComponent(
156
154
  }
157
155
 
158
156
  componentDidMount() {
159
- this._componentViewTag = this._getComponentViewTag();
160
157
  if (!IS_WEB) {
161
158
  // It exists only on native platforms. We initialize it here because the ref to the animated component is available only post-mount
162
159
  this._NativeEventsManager = new NativeEventsManager(this, options);
@@ -173,7 +170,7 @@ export function createAnimatedComponent(
173
170
 
174
171
  if (IS_WEB) {
175
172
  if (this.props.exiting) {
176
- saveSnapshot(this._component as HTMLElement);
173
+ saveSnapshot(this._componentRef as HTMLElement);
177
174
  }
178
175
 
179
176
  if (
@@ -189,11 +186,11 @@ export function createAnimatedComponent(
189
186
  if (!skipEntering) {
190
187
  startWebLayoutAnimation(
191
188
  this.props,
192
- this._component as ReanimatedHTMLElement,
189
+ this._componentRef as ReanimatedHTMLElement,
193
190
  LayoutAnimationType.ENTERING
194
191
  );
195
192
  } else {
196
- (this._component as HTMLElement).style.visibility = 'initial';
193
+ (this._componentRef as HTMLElement).style.visibility = 'initial';
197
194
  }
198
195
  }
199
196
 
@@ -209,7 +206,7 @@ export function createAnimatedComponent(
209
206
  this._configureSharedTransition(true);
210
207
  }
211
208
  this._sharedElementTransition?.unregisterTransition(
212
- this._componentViewTag,
209
+ this.getComponentViewTag(),
213
210
  true
214
211
  );
215
212
 
@@ -217,7 +214,7 @@ export function createAnimatedComponent(
217
214
 
218
215
  if (
219
216
  IS_WEB &&
220
- this._component &&
217
+ this._componentRef &&
221
218
  exiting &&
222
219
  !getReducedMotionFromConfig(exiting as CustomConfig)
223
220
  ) {
@@ -225,7 +222,7 @@ export function createAnimatedComponent(
225
222
 
226
223
  startWebLayoutAnimation(
227
224
  this.props,
228
- this._component as ReanimatedHTMLElement,
225
+ this._componentRef as ReanimatedHTMLElement,
229
226
  LayoutAnimationType.EXITING
230
227
  );
231
228
  } else if (exiting && !IS_WEB && !isFabric()) {
@@ -236,7 +233,7 @@ export function createAnimatedComponent(
236
233
  : getReduceMotionFromConfig();
237
234
  if (!reduceMotionInExiting) {
238
235
  updateLayoutAnimations(
239
- this._componentViewTag,
236
+ this.getComponentViewTag(),
240
237
  LayoutAnimationType.EXITING,
241
238
  maybeBuild(
242
239
  exiting,
@@ -248,31 +245,33 @@ export function createAnimatedComponent(
248
245
  }
249
246
  }
250
247
 
251
- _getComponentViewTag() {
248
+ getComponentViewTag() {
252
249
  return this._getViewInfo().viewTag as number;
253
250
  }
254
251
 
255
252
  _detachStyles() {
256
- if (this._componentViewTag !== -1 && this._styles !== null) {
253
+ const viewTag = this.getComponentViewTag();
254
+ if (viewTag !== -1 && this._styles !== null) {
257
255
  for (const style of this._styles) {
258
- style.viewDescriptors.remove(this._componentViewTag);
256
+ style.viewDescriptors.remove(viewTag);
259
257
  }
260
258
  if (this.props.animatedProps?.viewDescriptors) {
261
- this.props.animatedProps.viewDescriptors.remove(
262
- this._componentViewTag
263
- );
259
+ this.props.animatedProps.viewDescriptors.remove(viewTag);
264
260
  }
265
261
  if (isFabric()) {
266
- removeFromPropsRegistry(this._componentViewTag);
262
+ removeFromPropsRegistry(viewTag);
267
263
  }
268
264
  }
269
265
  }
270
266
 
271
267
  _updateFromNative(props: StyleProps) {
272
268
  if (options?.setNativeProps) {
273
- options.setNativeProps(this._component as AnimatedComponentRef, props);
269
+ options.setNativeProps(
270
+ this._componentRef as AnimatedComponentRef,
271
+ props
272
+ );
274
273
  } else {
275
- (this._component as AnimatedComponentRef)?.setNativeProps?.(props);
274
+ (this._componentRef as AnimatedComponentRef)?.setNativeProps?.(props);
276
275
  }
277
276
  }
278
277
 
@@ -285,24 +284,22 @@ export function createAnimatedComponent(
285
284
  let viewName: string | null;
286
285
  let shadowNodeWrapper: ShadowNodeWrapper | null = null;
287
286
  let viewConfig;
288
- // Component can specify ref which should be animated when animated version of the component is created.
289
- // Otherwise, we animate the component itself.
290
- const component = (this._component as AnimatedComponentRef)
291
- ?.getAnimatableRef
292
- ? (this._component as AnimatedComponentRef).getAnimatableRef?.()
293
- : this;
294
287
 
295
288
  if (SHOULD_BE_USE_WEB) {
296
289
  // At this point I assume that `_setComponentRef` was already called and `_component` is set.
297
290
  // `this._component` on web represents HTMLElement of our component, that's why we use casting
298
- viewTag = this._component as HTMLElement;
291
+ viewTag = this._componentRef as HTMLElement;
299
292
  viewName = null;
300
293
  shadowNodeWrapper = null;
301
294
  viewConfig = null;
302
295
  } else {
303
- // hostInstance can be null for a component that doesn't render anything (render function returns null). Example: svg Stop: https://github.com/react-native-svg/react-native-svg/blob/develop/src/elements/Stop.tsx
304
- const hostInstance = RNRenderer.findHostInstance_DEPRECATED(component);
296
+ const hostInstance = findHostInstance(this);
305
297
  if (!hostInstance) {
298
+ /*
299
+ findHostInstance can return null for a component that doesn't render anything
300
+ (render function returns null). Example:
301
+ svg Stop: https://github.com/react-native-svg/react-native-svg/blob/develop/src/elements/Stop.tsx
302
+ */
306
303
  throw new ReanimatedError(
307
304
  'Cannot find host instance for this component. Maybe it renders nothing?'
308
305
  );
@@ -313,7 +310,7 @@ export function createAnimatedComponent(
313
310
  viewName = viewInfo.viewName;
314
311
  viewConfig = viewInfo.viewConfig;
315
312
  shadowNodeWrapper = isFabric()
316
- ? getShadowNodeWrapperFromRef(this)
313
+ ? getShadowNodeWrapperFromRef(this, hostInstance)
317
314
  : null;
318
315
  }
319
316
  this._viewInfo = { viewTag, viewName, shadowNodeWrapper, viewConfig };
@@ -340,8 +337,6 @@ export function createAnimatedComponent(
340
337
  adaptViewConfig(viewConfig);
341
338
  }
342
339
 
343
- this._componentViewTag = viewTag as number;
344
-
345
340
  // remove old styles
346
341
  if (prevStyles) {
347
342
  // in most of the cases, views have only a single animated style and it remains unchanged
@@ -421,7 +416,7 @@ export function createAnimatedComponent(
421
416
  this._InlinePropManager.attachInlineProps(this, this._getViewInfo());
422
417
 
423
418
  if (IS_WEB && this.props.exiting) {
424
- saveSnapshot(this._component as HTMLElement);
419
+ saveSnapshot(this._componentRef as HTMLElement);
425
420
  }
426
421
 
427
422
  // Snapshot won't be undefined because it comes from getSnapshotBeforeUpdate method
@@ -433,7 +428,7 @@ export function createAnimatedComponent(
433
428
  ) {
434
429
  tryActivateLayoutTransition(
435
430
  this.props,
436
- this._component as ReanimatedHTMLElement,
431
+ this._componentRef as ReanimatedHTMLElement,
437
432
  snapshot
438
433
  );
439
434
  }
@@ -452,7 +447,7 @@ export function createAnimatedComponent(
452
447
  )
453
448
  : undefined;
454
449
  updateLayoutAnimations(
455
- this._componentViewTag,
450
+ this.getComponentViewTag(),
456
451
  LayoutAnimationType.LAYOUT,
457
452
  layout
458
453
  );
@@ -466,7 +461,7 @@ export function createAnimatedComponent(
466
461
  const { sharedTransitionTag } = this.props;
467
462
  if (!sharedTransitionTag) {
468
463
  this._sharedElementTransition?.unregisterTransition(
469
- this._componentViewTag,
464
+ this.getComponentViewTag(),
470
465
  isUnmounting
471
466
  );
472
467
  this._sharedElementTransition = null;
@@ -477,34 +472,42 @@ export function createAnimatedComponent(
477
472
  this._sharedElementTransition ??
478
473
  new SharedTransition();
479
474
  sharedElementTransition.registerTransition(
480
- this._componentViewTag,
475
+ this.getComponentViewTag(),
481
476
  sharedTransitionTag,
482
477
  isUnmounting
483
478
  );
484
479
  this._sharedElementTransition = sharedElementTransition;
485
480
  }
486
481
 
482
+ _resolveComponentRef = (ref: Component | HTMLElement | null) => {
483
+ const componentRef = ref as AnimatedComponentRef;
484
+ // Component can specify ref which should be animated when animated version of the component is created.
485
+ // Otherwise, we animate the component itself.
486
+ if (componentRef && componentRef.getAnimatableRef) {
487
+ return componentRef.getAnimatableRef();
488
+ }
489
+ return componentRef;
490
+ };
491
+
487
492
  _setComponentRef = setAndForwardRef<Component | HTMLElement>({
488
493
  getForwardedRef: () =>
489
494
  this.props.forwardedRef as MutableRefObject<
490
495
  Component<Record<string, unknown>, Record<string, unknown>, unknown>
491
496
  >,
492
497
  setLocalRef: (ref) => {
493
- // TODO update config
494
-
495
- const tag = findNodeHandle(ref as Component);
496
-
497
- // callback refs are executed twice - when the component mounts with ref,
498
- // and with null when it unmounts
499
- if (tag !== null) {
500
- this._componentViewTag = tag;
498
+ if (!ref) {
499
+ // component has been unmounted
500
+ return;
501
+ }
502
+ if (ref !== this._componentRef) {
503
+ this._componentRef = this._resolveComponentRef(ref);
504
+ // if ref is changed, reset viewInfo
505
+ this._viewInfo = undefined;
501
506
  }
507
+ const tag = this.getComponentViewTag();
502
508
 
503
509
  const { layout, entering, exiting, sharedTransitionTag } = this.props;
504
- if (
505
- (layout || entering || exiting || sharedTransitionTag) &&
506
- tag != null
507
- ) {
510
+ if (layout || entering || exiting || sharedTransitionTag) {
508
511
  if (!SHOULD_BE_USE_WEB) {
509
512
  enableLayoutAnimations(true, false);
510
513
  }
@@ -544,10 +547,6 @@ export function createAnimatedComponent(
544
547
  );
545
548
  }
546
549
  }
547
-
548
- if (ref !== this._component) {
549
- this._component = ref;
550
- }
551
550
  },
552
551
  });
553
552
 
@@ -557,9 +556,9 @@ export function createAnimatedComponent(
557
556
  getSnapshotBeforeUpdate() {
558
557
  if (
559
558
  IS_WEB &&
560
- (this._component as HTMLElement)?.getBoundingClientRect !== undefined
559
+ (this._componentRef as HTMLElement)?.getBoundingClientRect !== undefined
561
560
  ) {
562
- return (this._component as HTMLElement).getBoundingClientRect();
561
+ return (this._componentRef as HTMLElement).getBoundingClientRect();
563
562
  }
564
563
 
565
564
  return null;
@@ -2,25 +2,19 @@
2
2
  /* eslint-disable */
3
3
 
4
4
  import type { ShadowNodeWrapper } from './commonTypes';
5
+ import {
6
+ findHostInstance,
7
+ HostInstance,
8
+ } from './platform-specific/findHostInstance';
5
9
 
6
- let findHostInstance_DEPRECATED: (ref: unknown) => void;
7
10
  let getInternalInstanceHandleFromPublicInstance: (ref: unknown) => {
8
11
  stateNode: { node: unknown };
9
12
  };
10
13
 
11
14
  export function getShadowNodeWrapperFromRef(
12
- ref: React.Component
15
+ ref: React.Component,
16
+ hostInstance?: HostInstance
13
17
  ): ShadowNodeWrapper {
14
- // load findHostInstance_DEPRECATED lazily because it may not be available before render
15
- if (findHostInstance_DEPRECATED === undefined) {
16
- try {
17
- findHostInstance_DEPRECATED =
18
- require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;
19
- } catch (e) {
20
- findHostInstance_DEPRECATED = (_ref: unknown) => null;
21
- }
22
- }
23
-
24
18
  if (getInternalInstanceHandleFromPublicInstance === undefined) {
25
19
  try {
26
20
  getInternalInstanceHandleFromPublicInstance =
@@ -49,9 +43,9 @@ export function getShadowNodeWrapperFromRef(
49
43
  } else if (textInputRef) {
50
44
  resolvedRef = textInputRef;
51
45
  } else {
52
- resolvedRef = getInternalInstanceHandleFromPublicInstance(
53
- findHostInstance_DEPRECATED(ref)
54
- ).stateNode.node;
46
+ const instance = hostInstance ?? findHostInstance(ref);
47
+ resolvedRef =
48
+ getInternalInstanceHandleFromPublicInstance(instance).stateNode.node;
55
49
  }
56
50
 
57
51
  return resolvedRef;