EPguy

[React-Native, Android] Invariant Violation: requireNativeComponent: "RNSScreenStackHeaderConfig" was not found in the UIManager 에러 해결법 본문

개발/React-Native

[React-Native, Android] Invariant Violation: requireNativeComponent: "RNSScreenStackHeaderConfig" was not found in the UIManager 에러 해결법

EPguy 2023. 9. 26. 15:25

원인

아래 공식문서에 있는 내용을 따라하지 않으면 에러가 발생합니다.

해결방법

1. react-native-screens react-native-safe-area-context 라이브러리 설치
npm install react-native-screens react-native-safe-area-context

2. MainActivity.java 수정
아래 경로에 있는 MainActivity.java를 수정해야합니다.
android/app/src/main/java/<your package name>/MainActivity.java

아래 코드를 추가해주세요.

import android.os.Bundle;
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(null);
}

3. 프로젝트 재시작하기
설정을 반영하려면 재시작이 필요합니다.

npm run android