Skip to content

Commit

Permalink
Fix mappers cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kmagiera committed Nov 29, 2022
1 parent 53a51c6 commit d7d8569
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/reanimated2/ViewDescriptorsSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ export function makeViewDescriptorsSet(): ViewDescriptorsSet {
add: (item: Descriptor) => {
sharableViewDescriptors.modify((descriptors: Descriptor[]) => {
'worklet';
descriptors.push(item);
const index = descriptors.findIndex(
(descriptor) => descriptor.tag === item.tag
);
if (index !== -1) {
descriptors[index] = item;
} else {
descriptors.push(item);
}
return descriptors;
});
},
Expand Down
2 changes: 1 addition & 1 deletion src/reanimated2/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,5 @@ export function stopMapper(mapperID: number): void {
'worklet';
const mapperRegistry = global.__mapperRegistry;
mapperRegistry?.stop(mapperID);
});
})();
}

0 comments on commit d7d8569

Please sign in to comment.