Skip to content

Commit

Permalink
Fix animated refs on Fabric (software-mansion#3822)
Browse files Browse the repository at this point in the history
## Summary

This PR fixes crash on Fabric when using synchronous measure/scrollTo
etc – this error was a regression introduced in software-mansion#3722.

The issue was that did not transform shadow node wrapper ref into
shareable ref. Shareable ref was necessary for the UI side to recognize
and extract the shadow node wrapper that was needed for the sync calls
to execute.

## Test plan

Run FabricExample, use "Measure on UI" on the "Measure Example" screen
and "ScrollTo on UI" button on the "ScrollTo Example" screen.
  • Loading branch information
kmagiera authored and fluiddot committed Jun 5, 2023
1 parent efbf5b3 commit bf2f1fe
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/reanimated2/hook/useAnimatedRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@ import { getTag } from '../NativeMethods';
import { getShadowNodeWrapperFromHostInstance } from '../fabricUtils';
import {
makeShareableCloneRecursive,
makeShareableShadowNodeWrapper,
registerShareableMapping,
} from '../shareables';

function getShareableShadowNodeFromComponent(
component: Component
): ShadowNodeWrapper {
return makeShareableShadowNodeWrapper(
getShadowNodeWrapperFromHostInstance(component)
);
}

const getTagValueFunction = global._IS_FABRIC
? getShadowNodeWrapperFromHostInstance
? getShareableShadowNodeFromComponent
: getTag;

export function useAnimatedRef<T extends Component>(): RefObjectFunction<T> {
Expand Down

0 comments on commit bf2f1fe

Please sign in to comment.