Aharon Vishinsky
Aharon Vishinsky

Reputation: 373

React-Native passing style to props.children

I am trying to pass style to children, my code is :

render() {
    const RotateData = this.RotateValueHolder.interpolate({
        inputRange: [0, 1],
        outputRange: ['0deg', '360deg']
    });

    Object.assign(this.props.children.props.style,{'transform': [{'rotate': RotateData}] });

    return (
        <View style={{flex:1}}>
            {this.props.children}
        </View>
    );
}

I getting this error :

Invariant Violation: Transform with key of "rotate" must be a string:
{"rotate":"0deg"}

Upvotes: 1

Views: 667

Answers (1)

RANVIR GORAI
RANVIR GORAI

Reputation: 1286

Rotate can be only used by the animated component, so you need to apply the style to Animated.View or any Animated element. so try to use it with animated component.

Upvotes: 1

Related Questions