From 54efd725eba80d8f4792b68ed1091bfe32b059d1 Mon Sep 17 00:00:00 2001 From: kacperkapusciak Date: Tue, 12 Sep 2023 15:45:30 +0200 Subject: [PATCH 1/2] Add note about storing objects in shared values --- docs/docs/core/useSharedValue.mdx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/docs/core/useSharedValue.mdx b/docs/docs/core/useSharedValue.mdx index 11b1a30fe13..9590f204252 100644 --- a/docs/docs/core/useSharedValue.mdx +++ b/docs/docs/core/useSharedValue.mdx @@ -88,6 +88,22 @@ function App() { +- When storing objects in shared values, make sure to reassign an object instead of changing the properties individually. + + + +```javascript +function App() { + const sv = useSharedValue({ x: 0, y: 0 }); + + sv.value.x = 50; // Reanimated loses reactivity 🚨 + + sv.value = { x: 50, y: 50 }; // ✅ +} +``` + + + ## Platform compatibility
From a222aab6f3e4f65677c83e7da6f8a8b783f540d1 Mon Sep 17 00:00:00 2001 From: kacperkapusciak Date: Tue, 12 Sep 2023 15:50:25 +0200 Subject: [PATCH 2/2] Grammar --- docs/docs/core/useSharedValue.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/core/useSharedValue.mdx b/docs/docs/core/useSharedValue.mdx index 9590f204252..96b5cb34025 100644 --- a/docs/docs/core/useSharedValue.mdx +++ b/docs/docs/core/useSharedValue.mdx @@ -88,7 +88,7 @@ function App() { -- When storing objects in shared values, make sure to reassign an object instead of changing the properties individually. +- When storing objects in a shared value, make sure to reassign an object instead of changing the properties individually.