2017-01-30 5 views
17

보간 된보기로 애니메이션을 적용하려고합니다. 내 Animated.Value의 현재 값을 가져오고 싶지만 어떻게해야할지 모르겠다. 나는 React-native docs으로 그것을하는 방법을 이해하지 못했습니다.Animated.Value, React-native의 현재 값을 가져옵니다.

this.state = { 
     translateAnim: new Animated.Value(0) 
} 
DeviceEventEmitter.addListener('Accelerometer', function (data) { 
    console.log(this.state.translateAnim);//returns an object, but I need a 
              value in current moment 
} 

답변

31

내가 찾아, 값을 얻는 방법 :

는 다음 작업을 수행 할 값을 기록 할

this.state.translateAnim.addListener(({value}) => this._value = value); 

편집 :

console.log(this.state.translateAnim._value) 
+0

를 TSC는 나에게 경고를 함께 : '속성'_value '가'값 '유형에 없습니다.' – jose920405

관련 문제