Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions packages/react-native-reanimated/src/updateProps/updateProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { isFabric, isJest, shouldBeUseWeb } from '../PlatformChecker';
import type { ReanimatedHTMLElement } from '../ReanimatedModule/js-reanimated';
import { _updatePropsJS } from '../ReanimatedModule/js-reanimated';
import { runOnJS, runOnUIImmediately } from '../threads';
import { processTransformOrigin } from './processTransformOrigin';
import { ComponentRegistry } from './ComponentRegistry';
import { processTransformOrigin } from './processTransformOrigin';

let updateProps: (
viewDescriptors: ViewDescriptorsWrapper,
Expand Down Expand Up @@ -76,15 +76,31 @@ export const updatePropsJestWrapper = (

export default updateProps;

// Apply thr changes from UI thread to JS thread.Add commentMore actions
let updatesToReactJS: { [tag: string]: StyleProps } = {};

function flushUpdatesToReactJS() {
Object.keys(updatesToReactJS).forEach((tagStr) => {
const tag = Number(tagStr);
const props = updatesToReactJS[tag];
const component = ComponentRegistry.getComponent(tag);
if (component) {
component._updateReanimatedProps(props);
}
})
updatesToReactJS = {}
}

let timeoutId: NodeJS.Timeout | undefined;
// Apply the changes from UI thread to JS thread.
function updatePropsOnReactJS(tag: number, props: StyleProps) {
const component = ComponentRegistry.getComponent(tag);
if (component) {
component._updateReanimatedProps(props);
updatesToReactJS[tag] = {
...updatesToReactJS[tag],
...props,
}
clearTimeout(timeoutId);
timeoutId = setTimeout(flushUpdatesToReactJS, 0) ;
}


const createUpdatePropsManager = isFabric()
? () => {
'worklet';
Expand Down
Loading