Skip to main content
Version: Unreleased

removeSerializableMapping

Available from 0.14.0

Makes Worklets forget the mapping of an object, whether it came from setSerializableMapping or from an earlier serialization. The next time the object is serialized, Worklets serializes the object itself and remembers the new mapping.

Reference​

import {
removeSerializableMapping,
scheduleOnUI,
setSerializableMapping,
} from 'react-native-worklets';

const flag = { current: false };
setSerializableMapping(flag, { current: true });
removeSerializableMapping(flag);

scheduleOnUI(() => {
console.log(flag.current); // logs `false`
});

Type definitions

function removeSerializableMapping(value: object): void;

Arguments​

value​

The object whose mapping to remove. It's compared by reference.

Remarks​

  • removeSerializableMapping also removes mappings that Worklets or other libraries set.
  • If value has no mapping, removeSerializableMapping does nothing.
  • Passing a SerializableRef does nothing.
  • On the Web removeSerializableMapping does nothing.