لدي عرض دائري أريد فيه تحريك لون الحدود باستخدام قيمة Animated.Value تتغير بين 0 و 1. باتباع الدليل من https://facebook.github.io/react-native/docs/animated. html انتهى بي الأمر باستخدام دالة الإقحام في Animated.Value.
borderColor: this.state.active.interpolate({
inputRange: [0, 1],
outputRange: ['rgba(0, 0, 0, 0)', 'rgba(0, 0, 0, 1)']
})
يؤدي هذا إلى إنشاء تحذير في التطبيق (Android):
index.android.bundle:29278Warning: Failed propType: Invalid prop `borderColor` supplied to `View`: [object Object]
Valid color formats are
- '#f0f' (#rgb)
- '#f0fc' (#rgba)
- '#ff00ff' (#rrggbb)
- '#ff00ff00' (#rrggbbaa)
- 'rgb(255, 255, 255)'
- 'rgba(255, 255, 255, 1.0)'
- 'hsl(360, 100%, 100%)'
- 'hsla(360, 100%, 100%, 1.0)'
- 'transparent'
- 'red'
- 0xff00ff00 (0xrrggbbaa)
Bad object: {
"borderWidth": 2,
"justifyContent": "center",
"alignItems": "center",
"width": 200,
"height": 200,
"borderRadius": 100,
"borderColor": "rgba(0, 0, 0, 0)"
} Check the render method of `Circle`.
من التحذير أعلاه ، يبدو أن borderColor صحيحًا. ومع ذلك ، فإنه لا يزال يعطي التحذير.
تم إصلاحه باستخدام <Animated.View>
بدلاً من <View>
التعليق الأكثر فائدة
تم إصلاحه باستخدام
<Animated.View>
بدلاً من<View>