React Native Reanimated: аргумент типа AnimatedNode <number> не может быть назначен параметру типа number.ts(2345)
Мне нужно создать анимацию ящика с помощью React Native Reanimated(https://www.npmjs.com/package/react-native-reanimated).
перед обновлением метод интерполяции работает правильно с двумя аргументами. который используется как
interpolate(
props.progress,
{
[0, 1],
[1, 0.85],
Extrapolate.CLAMP
}
);
Но после обновления метод примет от 3 до 4 параметров
interpolate(
props.progress,
[0, 1],
[1, 0.85],
Extrapolate.CLAMP
);
Теперь я получил ошибку, как показано ниже
Argument of type 'AnimatedNode<number>' is not assignable to parameter of type 'number'
Моя текущая версия React Native Reanimated - 2.1.0.
Передача Props через drawerContent (DrawerContentComponentProps), как показано ниже
drawerContent={(props) => {
const scale = interpolate(
props.progress,
[0, 1],
[1, 0.85],
Extrapolate.CLAMP
);
const borderRadius = interpolate(
props.progress,
[0, 1],
[0, 10],
Extrapolate.CLAMP
);
screenStyle = {
transform: [
{
scaleY: scale,
},
],
borderRadius,
};
return <SideBar {...props} user={user} />;
}}
```
1 ответ
Решение
В Reanimated 2 интерполяция была переименована в interpolateNode. Итак, я изменил свой код, например
...
const scale = interpolateNode(props.progress, {
inputRange: [0, 1],
outputRange: [1, 0.85],
extrapolate: Extrapolate.CLAMP,
});
const borderRadius = interpolateNode(props.progress, {
inputRange: [0, 1],
outputRange: [1, 10],
extrapolate: Extrapolate.CLAMP,
});
...
И это сработало правильно