Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating LottieView progress via useAnimatedProps broken #4674

Closed
AlexanderEggers opened this issue Jul 5, 2023 · 4 comments · Fixed by #4821
Closed

Updating LottieView progress via useAnimatedProps broken #4674

AlexanderEggers opened this issue Jul 5, 2023 · 4 comments · Fixed by #4821
Labels
Needs review Issue is ready to be reviewed by a maintainer Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snippet of code, snack or repo is provided

Comments

@AlexanderEggers
Copy link
Contributor

AlexanderEggers commented Jul 5, 2023

Description

When trying to update the progress of a LottieView (lottie-react-native) via the useAnimatedProps hook, the actual update is not received by the component and nothing seems to change on the screen. That used to work in v2 without issues.

Possible workaround for a few cases but not all:

  const animationProgressController = useSharedValue(0);

  const animatedProps = useAnimatedProps(() => ({
    progress: animationProgressController.value,
  }));
  const [progress, setProgress] = useState<number>(0);
  useDerivedValue(() => {
    runOnJS(setProgress)(animationProgressController.value);
  }, [animationProgressController]);

Steps to reproduce

  1. Checkout https://github.com/AlexanderEggers/ReanimatedIssue/tree/reanimated-hook-issue
  2. You will notice that nothing happens on the screen
  3. Update the reanimated version to the latest v2
  4. Run the application again and the lottie animation progress is now correctly handled

Snack or a link to a repository

https://github.com/AlexanderEggers/ReanimatedIssue/tree/reanimated-hook-issue

Reanimated version

3.3.0

React Native version

0.71.11

Platforms

Android, iOS

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

@AlexanderEggers AlexanderEggers added the Needs review Issue is ready to be reviewed by a maintainer label Jul 5, 2023
@github-actions github-actions bot added Repro provided A reproduction with a snippet of code, snack or repo is provided Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS labels Jul 5, 2023
@AlexanderEggers
Copy link
Contributor Author

AlexanderEggers commented Jul 5, 2023

@tomekzaw This is the other blocking issue in my project to update reanimated to v3 that I have mentioned here.

@tomekzaw
Copy link
Member

tomekzaw commented Jul 5, 2023

@AlexanderEggers Thanks for submitting the issue as well as providing the repro, currently I'm quite busy but I will take a look at it soon.

@AlexanderEggers
Copy link
Contributor Author

@tomekzaw Do you have any updates yet?

@LeoAnt02
Copy link

Any update on this ? @tomekzaw

github-merge-queue bot pushed a commit that referenced this issue Aug 4, 2023
## Summary

Reintroduce support for jsProps. 
Closes
#4317
and closes
#4674

It turns out that jsProps are still in use by many libraries like
`react-native-lottie` and `react-native-svg`.


> **Note**
> This fix does not work for fabric 😢 However Lottie animations are not
implemented for Fabric anyway 😎

<!-- Explain the motivation for this PR. Include "Fixes #<number>" if
applicable. -->
<table>
<tr><td>BEFORE</td><td>AFTER</td></tr>

<tr><td>The white dot does not move ❌</td><td>The white dot moves
✅</td></tr>
<tr><td>


https://github.com/software-mansion/react-native-reanimated/assets/56199675/3c961690-383c-45dc-83ec-5801e13473bf

</td><td>


https://github.com/software-mansion/react-native-reanimated/assets/56199675/bf900564-cb5a-43cb-b2ef-2d21794727a1

</td></tr>
</table>

## Test plan

Tested on this example:
https://github.com/acollazomayer/ReanimatedSVGBug

---------

Co-authored-by: Aleksandra Cynk <aleksandracynk@swmansion.com>
Co-authored-by: Aleksandra Cynk <aleksandra.cynk@swmansion.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs review Issue is ready to be reviewed by a maintainer Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snippet of code, snack or repo is provided
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants