UseTransition() and Reanimated 1.3.0
See original GitHub issueI am getting a weird behaviour with different animations after updating to react-native-reanimated
1.3.0.
Here my specs:
"react-native-gesture-handler": "^1.4.0",
"react-native-redash": "^8.1.2",
"react-native-reanimated": "1.3.0",
"react-native": "0.61.1",
"react": "16.9.0",
The animation gets triggered every time as shown in the video below:
Here the code:
const [isOnFocus, setOnFocus] = useState<0 | 1>(0);
let animatedValue = isOnFocus || value ? 1 : 0;
const transition = useTransition(
animatedValue,
not(animatedValue),
animatedValue,
160,
Easing.ease,
);
const inputRange = [0, 1];
const fontSize = interpolate(transition, {
inputRange,
outputRange: [18, 10],
});
const top = interpolate(transition, {
inputRange,
outputRange: [20, 5],
});
return (...);
It used to work with Reanimated 1.2.0, but I need to upgrade it due to other problems.
Any suggestions? Am I missing something? Thanks for the help in advance 😃
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
93 Versions - react-native-reanimated - npm
More powerful alternative to Animated library for React Native.. Latest version: 2.13.0, last published: a month ago.
Read more >Getting started - React Navigation
React Navigation is born from the React Native community's need for an extensible yet easy-to-use navigation solution written entirely in JavaScript (so you ......
Read more >useTransition and useDeferredValue in React 18
We can use the useTransition hook to tell React that a certain state change will result in an expensive rendering.
Read more >William Candillon on Twitter: "Reanimated 1.3.0 ships support ...
Reanimated 1.3.0 ships support for string animation values on Android. We'll celebrate it on YouTube by animating some bezier curves.
Read more >React 18's useTransition() Hook: Master in 2 Minutes
0. React v18 is a newly released version of React, which introduces many new features like Automatic Batching, new APIs like useTransition() ,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This particular issue didn’t appear to be fixed, will test it further
We found the solution together with @warrioru. The problem of
react-native-reanimated 1.3.0
is that is causes a re-render in the hook everytime the animatedValue gets updated.the soluton was to introduce a
componentDidUpdate
hook for checking the prev state. the animation happens now only when the animated state changes.