Skip to main content
Version: 0.14

getSerializableMapping

Available from 0.14.0

Returns the SerializableRef that Worklets sends to other Runtimes in place of an object. An object has one after setSerializableMapping, or after Worklets serialized it.

Reference​

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

const flag = { current: false };
console.log(getSerializableMapping(flag)); // logs `undefined`

setSerializableMapping(flag, { current: true });
// the SerializableRef of `{ current: true }`
const mapping = getSerializableMapping(flag);

Type definitions

function getSerializableMapping(value: object): SerializableRef | undefined;

Arguments​

value​

The object to get the mapping of. It's compared by reference.

Returns​

The SerializableRef mapped to value, or undefined if value has no mapping.

Remarks​

  • On the Web getSerializableMapping always returns undefined.