Question from the React Native (Legacy) test

Write a React Native animation that spins an image.

Hard

En React Native, comment décrirez vous cette animation ?

import React from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Animated,
  Image,
  Easing
} from 'react-native'

class AnimationExample extends React.Component {
	constructor () {
	  super()
	  this.animValue = new Animated.Value(0)
	}
	componentDidMount () {
  		this.animate()
	}
	animate () {
	  this.animValue.setValue(0)
	  Animated.timing(
	    this.animValue,
	    {
	      toValue: 1,
	      duration: 4000,
	      easing: Easing.linear
	    }
	  ).start(() => this.animate())
	}
	render () {
	  const anim = this.animValue.interpolate({
	    inputRange: [0, 1],
	    outputRange: ['0deg', '360deg']
	  })
	  return (
	    <View style={styles.container}>
	      <Animated.Image
	        style={{
	          width: 227,
	          height: 200,
	          transform: [{rotate: anim}] }}
	          source={{uri: 'https://s3.amazonaws.com/media-p.slid.es/uploads/alexanderfarennikov/images/1198519/reactjs.png'}}
	      />
	    </View>
	  )
	}
}

Author: Victor SabatierStatus: PublishedQuestion passed 474 times
Edit
5
Community EvaluationsNo one has reviewed this question yet, be the first!