Give more meaningful warning when modifying a Shareable
Summary
Wanted to open this PR for a long time.
Currently we use Object.freeze in development on objects after they were converted to a Shareable. This is problematic for users since there is no information about why is the object immutable all of a sudden.
While this PR won't give a meaningful error when user tries to add a new property to the object when doing something like:
const a = {};
function foo(){
'worklet';
console.log(a.b);
};
runOnUI(worklet)();
a.b = 1;
runOnUI(worklet)();
but it seems to be a rare case and mostly the problems are with modifying existing properties.
Test plan
const a = { b: 1 };
makeShareableCloneRecursive(a);
a.b = 2; // Warning here.
@tomekzaw I moved docs and examples part to a separate PR #5560 after applying review suggestions
@tomekzaw @tjzel this PR crashes our App (after upgrade to 3.12.0) . It crashes on launch with 'property is not configurable'. Any insights into debugging will be appreciated , it crashes at shareables.ts: 321 . https://github.com/software-mansion/react-native-reanimated/issues/6082
@giantslogik It's fixed.