我有一个组件,其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
?
Animated.Value
。请参见:https://facebook.github.io/react-native/docs/animations。另请参阅:https://github.com/DefinitelyTyped/DefinitelyTyped/issues/12202以整合此功能到核心库中。 - Nico Burns