Features:
Render in a JS Thread (most common scenario)
Render in the UI Thread (high priority event on the UI Thread)
function MyComponent() {
return (
<View>
<Text>Hello, World</Text>
</View>
)
}
React Shadow Tree -> Host View Tree
function MyComponent() {
return (
<View>
<View style={{ backgroundColor: 'red', height: 20, width: 20 }} />
<View style={{ backgroundColor: 'blue', height: 20, width: 20 }} />
</View>
)
}
Assume that as the result of a state update in JavaScript product logic, the background of the first nested
<View>
<View style={{ backgroundColor: 'yellow', height: 20, width: 20 }} />
<View style={{ backgroundColor: 'blue', height: 20, width: 20 }} />
</View>
Let’s explore each phase of the render pipeline during a state update.
Let's assign T to the “previously rendered tree” and T' to the “new tree”:
const translateX = useRef(new Animated.Value(0)).current
//...
Animated.timing(translateXRefValue, {
toValue: 200,
duration,
easing: Easing.inOut(Easing.linear),
useNativeDriver: true,
}).start()
Weex bindingx
60fps Record Video
vs
120fps Record Video
https://www.zhihu.com/question/21081976
When you pause a movie, you can see the image is blur
https://docs.swmansion.com/react-native-reanimated/
easily create smooth animations and interactions that run on the UI thread.
https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/
https://gaohaoyang.github.io/2021/03/01/spring-animation-framer-motion/
Haoyang Gao
2023.11.17