How to write this functional state to be class state? I usually know how to change this in general, but what confuses me a lot here is because this third const state uses some other state inside itself, state const scrollAnim is used inside third state. So I dont understand how to write this for class component because this is written inside functional.
const [scrollAnim] = useState(new Animated.Value(0));
const [offsetAnim] = useState(new Animated.Value(0));
const [clampedScroll, setClampedScroll] = useState(Animated.diffClamp(
Animated.add(
scrollAnim.interpolate({
inputRange: [0, 1],
outputRange: [0, 1],
extrapolateLeft: 'clamp'
}),
offsetAnim
), 0, 1
));
What I tried:
state = {
scrollAnim: (new Animated.Value(0)),
offsetAnim: (new Animated.Value(0)),
clampedScroll: (Animated.diffClamp(
Animated.add(
scrollAnim.interpolate({
inputRange: [0, 1],
outputRange: [0, 1],
extrapolateLeft: 'clamp'
}),
offsetAnim
), 0, 1
))
};