error: RN | Animated 'useNativeDriver' is declared here. - 221021

Lumpen·2022년 10월 21일
0

Error

목록 보기
16/41

TS2345: Argument of type '{ toValue: number; duration: number; }' is not assignable to parameter of type 'TimingAnimationConfig'. Property 'useNativeDriver' is missing in type '{ toValue: number; duration: number; }' but required in type 'TimingAnimationConfig'.

Animated

react native에서 css 애니메이션을 구현할 때 사용

import { Animated } from 'react-native'

const value = React.useRef(new Animated.Value(0)).current

useEffect(() => {
	Animated.timing(value, {
      toValue: 1,
      duration: 10000
    })
}, [value])

공식문서에서 이렇게 나와있는데 위와 같은 에러 발생

useNativeDriver: true
추가하면 해결된다

  React.useEffect(() => {
    Animated.timing(value, {
      toValue: 1,
      duration: 10000,
      useNativeDriver: true,
    }).start();
  }, [value]);
profile
떠돌이 생활을 하는. 실업자는 아니지만, 부랑 생활을 하는

0개의 댓글