1- import { StyleSheet , type ViewProps } from 'react-native' ;
1+ import { StyleSheet , type ViewProps , type ViewStyle } from 'react-native' ;
22import NativeEaseView from './EaseViewNativeComponent' ;
33import type { AnimateProps , Transition } from './types' ;
44
5+ export type EaseViewStyle = Omit < ViewStyle , 'opacity' | 'transform' > ;
6+
57const IDENTITY : Required < AnimateProps > = {
68 opacity : 1 ,
79 translateX : 0 ,
@@ -10,10 +12,11 @@ const IDENTITY: Required<AnimateProps> = {
1012 rotate : 0 ,
1113} ;
1214
13- export type EaseViewProps = ViewProps & {
15+ export type EaseViewProps = Omit < ViewProps , 'style' > & {
1416 animate ?: AnimateProps ;
1517 initialAnimate ?: AnimateProps ;
1618 transition ?: Transition ;
19+ style ?: EaseViewStyle | EaseViewStyle [ ] ;
1720} ;
1821
1922export function EaseView ( {
@@ -26,19 +29,17 @@ export function EaseView({
2629 const resolved = { ...IDENTITY , ...animate } ;
2730 const resolvedInitial = { ...IDENTITY , ...( initialAnimate ?? animate ) } ;
2831
29- // Strip animated properties from style
32+ // Strip animated properties from style at runtime as a safety net
3033 let cleanStyle = style ;
31- if ( style ) {
32- const flat = StyleSheet . flatten ( style ) ;
33- if ( flat ) {
34- const { opacity, transform, ...remaining } = flat ;
35- if ( __DEV__ && ( opacity !== undefined || transform !== undefined ) ) {
36- console . warn (
37- 'react-native-ease: Set opacity/transforms in the animate prop, not style. ' +
38- 'Animated properties in style will be ignored.'
39- ) ;
40- }
41- cleanStyle = remaining ;
34+ if ( __DEV__ && style ) {
35+ const flat = StyleSheet . flatten ( style as ViewStyle ) as Record < string , unknown > ;
36+ if ( flat && ( 'opacity' in flat || 'transform' in flat ) ) {
37+ console . warn (
38+ 'react-native-ease: Set opacity/transforms in the animate prop, not style. ' +
39+ 'Animated properties in style will be ignored.'
40+ ) ;
41+ const { opacity : _o , transform : _t , ...remaining } = flat ;
42+ cleanStyle = remaining as EaseViewStyle ;
4243 }
4344 }
4445
0 commit comments