[React Native] 개발 환경 변경 후 바뀐점

네민·2023년 9월 26일
0
post-thumbnail

💬 졸작 중 expo bare workflow -> react native cli로 개발 환경 변경

1. 실행 명령어 변경

❌ 변경 전

npx expo start --dev-client

⭕ 변경 후

npx react-native run-android

2. expo-secure-store 사용 불가능

로그인을 토큰 형식으로 해서 저장해두고 있었는데 사용이 불가능하게 됨
-> react-native-sensitive-info로 변경

📌 설치

npm i react-native-sensitive-info

❌ 변경 전

import * as SecureStore from 'expo-secure-store';

// 데이터 저장
SecureStore.setItemAsync('Token', 'yourTokenValue');

// 데이터 검색
SecureStore.getItemAsync('Token');

⭕ 변경 후

import SInfo from 'react-native-sensitive-info';

// 데이터 저장
SInfo.setItem('Token', 'yourTokenValue', {});

// 데이터 검색
SInfo.getItem('Token', {}).then(value => {
  if (value) {

  } else {
    console.log('토큰 없음');
  }
});

3. expo/vector-icons 사용 불가능

📌 설치

npm i react-native-vector-icons

📌 설정

// android/app/build.gradle

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle" <-- 추가

❌ 변경 전

import { AntDesign } from '@expo/vector-icons';

<AntDesign name="left" size={24} color="black" />

⭕ 변경 후

https://ionic.io/ionicons 얘를 사용했음

import Icon from 'react-native-vector-icons/Ionicons';

<Icon name="chevron-back-outline" size={24} color={tintColor} />

4. react-native-gesture-handler 오류

📌 설치

npm i react-native-gesture-handler

간단하게 설치만 해주면 해결됐다


이것저것 변경하느라 힘들었지만
예전 오류들이 싹 사라져서 바꾼 후 행복하다 💙

profile
기록하자

0개의 댓글