【发布时间】:2019-01-02 10:40:34
【问题描述】:
我有一个组件,其 Props 接口从 React Native 扩展 ViewProps,即:
export interface Props extends ViewProps {
// Custom props
}
当然,这扩展了 style 属性。有一个警告,我使用的是Animated.View 并且有这样的风格:
style={{
opacity: animationCharacter.interpolate({
inputRange: [0, 1],
outputRange: [0, 1]
}),
transform: [
{
scale: animationCharacter.interpolate({
inputRange: [0, 1],
outputRange: [1.2, 1]
})
}
]
}}
我认为interpolate 调用与来自ViewProps 的样式类型不兼容,但没有可以扩展的AnimatedViewProps。
这里有解决方案还是我必须设置style: any?
【问题讨论】:
-
我认为我没有足够的能力来提供答案,但我做了一些研究,似乎对 interpolate 的调用产生了
Animated.Value。 facebook.github.io/react-native/docs/animations。另请参阅:github.com/DefinitelyTyped/DefinitelyTyped/issues/12202 将其集成到核心库中的工作,
标签: typescript react-native typescript-typings