From 8ff5b88c56bd38aecc9bd4a61cc832713ed88acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Szyd=C5=82owski?= <9szydlowski9@gmail.com> Date: Tue, 9 Jul 2024 11:50:32 +0200 Subject: [PATCH] Revert dynamic styles PR (#6218) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Unfortunately, turns out the PR with dynamic styles #5268 introduced more problems than it solved. Thus, proposing a revert. This revert most likely fixed: - https://github.com/software-mansion/react-native-reanimated/issues/6203 - https://github.com/software-mansion/react-native-reanimated/issues/6102 - https://github.com/software-mansion/react-native-reanimated/issues/6037 as well as one more not-published issue and potentially a few more. ## Notes Even if it gets approved, to be merged ONLY after @tjzel agrees with everything ## Test plan ๐Ÿ˜ข ๐Ÿ˜ญ --- .../src/examples/DynamicStylesExample.tsx | 216 ------------------ apps/common-app/src/examples/index.ts | 6 - .../InlinePropManager.ts | 4 +- .../createAnimatedComponent/PropsFilter.tsx | 28 +-- 4 files changed, 5 insertions(+), 249 deletions(-) delete mode 100644 apps/common-app/src/examples/DynamicStylesExample.tsx diff --git a/apps/common-app/src/examples/DynamicStylesExample.tsx b/apps/common-app/src/examples/DynamicStylesExample.tsx deleted file mode 100644 index fa538f49c19..00000000000 --- a/apps/common-app/src/examples/DynamicStylesExample.tsx +++ /dev/null @@ -1,216 +0,0 @@ -import { Text, StyleSheet, View, Button } from 'react-native'; - -import React from 'react'; - -import Animated, { - useAnimatedStyle, - useSharedValue, - withTiming, -} from 'react-native-reanimated'; - -export default function DynamicStylesExample() { - const [extraStyle, setExtraStyle] = React.useState(false); - const [rerender, setRerender] = React.useState(false); - - const widthShared = useSharedValue(80); - const backgroundColorShared = useSharedValue('rgb(255,127,63)'); - - const animatedWidthStyle = useAnimatedStyle(() => ({ - width: widthShared.value, - })); - const animatedBackgroundColorStyle = useAnimatedStyle(() => { - return { - backgroundColor: backgroundColorShared.value, - }; - }); - - function handleChangeProps() { - setExtraStyle((extraStyle) => !extraStyle); - } - - function handleAnimate() { - widthShared.value = withTiming((Math.random() * 160) / 2 + 40, { - duration: 1000, - }); - - const r = Math.random() * 256; - const g = Math.random() * 256; - const b = Math.random() * 256; - - backgroundColorShared.value = withTiming(`rgb(${r},${g},${b})`, { - duration: 1500, - }); - } - - function handleForceRerender() { - setRerender(!rerender); - } - - return ( - - State: {String(rerender)} - - - InlineStyles - - Same length array - - - Different length array - - Same length extra plain style array - - - Different length extra plain style array - - - - Two animated styles independent of state - - - - - useAnimatedStyle - - Same length array - - Different length array - - Same length extra plain style array - - - Different length extra plain style array - - - - Two animated styles independent of state - - - - - - - {extraStyle ? '' : 'no '}extra animated style - -