01. 변수가 필요하다면, Animated에서 생성해서 사용한다.
state로 변수를 생성하면 모든 컴포넌트가 re-rendering(다시 그리기) 돼버린다. 그러므로 Animated에서 무조건 생성한다.
#초기값이 0인 변수 Y를 생성한다.
const Y = new Animated.Value(0);
02. 변수에 값을 변경한다면 절대 절대 절대 절대 이렇게 하지 않는다.
# 변수값을 직접 변경하지 않는다.
Y = 20
03. Animated 될 수 있는 것에만 Animated 를 시도한다. ㅋㅋ
createAnimatedComponent()를 사용해서 Animatable component로 변경한 뒤에 사용한다.
# 이렇게 하지 않는다.
<Animated.View .. #View 자체를 Animated 하지 않는다.
createAnimatedComponent() can be used to make a component animatable.
즉,
아래 내용처럼 주어진 것을 그대로 사용하거나 createAnimatedComponent() 를 사용해서 새로 생성한 뒤에 사용한다.
Animated.Image
Animated.ScrollView
Animated.Text
Animated.View
Animated.FlatList
Animated.SectionList
생성 예)
import styled from "styled-components/native";
const Box = styled.TouchableOpacity``;
const AnimatedBox = Animated.createAnimatedComponent(Box);
다음글
2023.01.31 - [개발로그/ReactNative] - React Native Animated - 애니메이션 value 를 수정하기 위해 사용하는 것들. 예제 포함
2023.02.01 - [개발로그/ReactNative] - 에러가 있는 코드로부터 배운다. React Native Animated 에서의 Value 수정하기(useRef)
728x90
'개발로그 > ReactNative' 카테고리의 다른 글
시뮬레이터를 지정해서 테스트 하는 방법 (0) | 2023.02.08 |
---|---|
2023. ver2. admob IOS 앱 첫 연동하기 예제 CRNA app (Expo Dev Client and EAS CLI) (0) | 2023.02.06 |
에러가 있는 코드로부터 배운다. React Native Animated 에서의 Value 수정하기(useRef) (0) | 2023.02.01 |
React Native Animated - 애니메이션 value 를 수정하기 위해 사용하는 것들. 예제 포함 (0) | 2023.01.31 |
처음부터 다시 해보는 npx create-react-native-app dear-diary with ios 세팅! 나만의 프리셋 (0) | 2023.01.31 |
처음부터 해보는 npx react-native init AwesomeProject with ios 세팅! 나만의 프리셋 (0) | 2023.01.30 |
**BUILD FAILD** xcode_env_generator 를 생성시키는 버전으로 expo-modules-autolinking 의 버전을 맞춰보자. (0) | 2023.01.29 |
React Query 에서 모든 캐쉬된 쿼리에 권한을 갖는 QueryClient 사용법 그리고 개념정리 (0) | 2023.01.27 |
댓글