react-native-reanimated
react-native-reanimated copied to clipboard
feat(Worklets): support for cloning Set and Map
Summary
Adding the possibility to clone Map and Set without init function tricks. Cloning works only from RN Runtime to the UI Runtime, do we want to make it symmetric even with legacy bundling?
I'm waiting to merge #7598 first so I can add relevant runtime checks.
Test plan
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { runOnUI } from 'react-native-worklets';
export default function EmptyExample() {
const map = new Map<unknown, unknown>([
[1, 1],
['2', '2'],
[{ 3: 3 }, { 3: 3 }],
]);
const set = new Set<unknown>([1, '2', { 3: 3 }]);
React.useEffect(() => {
runOnUI(() => {
console.log('Map:', map);
for (const [key, value] of map) {
console.log('Key:', key, 'Value:', value);
}
console.log('Set', set);
for (const value of set) {
console.log('Value:', value);
}
})();
});
return (
<View style={styles.container}>
<Text>Hello world!</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
});