question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useReanimatedProps with custom component not updating on iOS

See original GitHub issue

Description

I’m trying to update text like ReText from react-native-redash. This is working correctly on Android but not on iOS.

Screenshots

Android (where it is working): screen-recording-android

Steps To Reproduce

  1. Update shared value
  2. Update text via animatedProps

Expected behavior

Text should update without rerender.

Actual behavior

Text does not update.

Snack or minimal code example

const sliderValue = useSharedValue(25);

const formatted = useDerivedValue( () => ${sliderValue.value}, [currentSliderValue], );

<ReText text={formatted} style={{ color: ‘black’ }} />

Package versions

  • React: 16.13.1
  • React Native: 0.63.2
  • React Native Reanimated: 2.0.0-rc.1
  • NodeJS: v12.16.2
  • React Native Redash: 16.0.4

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Szymon20000commented, Dec 31, 2020
import React, { useEffect } from "react";
import { StyleSheet, View } from "react-native";
import { ReText } from 'react-native-redash';
import Animated, {
  useAnimatedStyle,
  useDerivedValue,
  useSharedValue,
  withSpring,
  withTiming,
} from "react-native-reanimated";

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  card: {
    position: "absolute",
    top: 0,
    left: 0,
    width: 100,
    height: 50,
  },
});

const DynamicSpring = () => {
  const x = useSharedValue('0deg');
  useEffect(() => {
    x.value = withTiming('300deg', { duration: 5000 });
  });
  
  return (
    <View style={styles.container}>
      <ReText
        text={x}
        style={{ color: "black", fontVariant: ["tabular-nums"] }}
      />
    </View>
  );
};

export default DynamicSpring;
0reactions
eliaslecomtecommented, Jan 7, 2021

The PR https://github.com/software-mansion/react-native-reanimated/pull/1584 does fix it for my app on iOS 👍 . I can’t test if there are consequences for Android as I have an issue with building it from that commit 😖 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Updating custom props on UI thread does not work on iOS
When using third party components it is no longer possible to register additional properties to be updated directly on the UI thread. With ......
Read more >
React Native Reanimated + SVG + Custom Component Not ...
I am trying to create a custom svg component (a rocket) that I then turn into an animated component using reanimated, so that...
Read more >
useAnimatedProps | React Native Reanimated
The animatedProps property is added when a native component is wrapped with Animated.createAnimatedComponent . If the animated props worklet uses any shared ...
Read more >
Updating a state causes animation in animatedProps to reset ...
Coding example for the question Reanimated 2: Updating a state causes animation in animatedProps to reset despite not changing the shared value-React ...
Read more >
Reanimated 2 - the new approach to creating animations in ...
We are going to build practical examples of animated sliders using the new Reanimated 2 API and our custom useSlider hook.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found