개발일지

React Navigation - native-stack 뒤로가기 방지 오류 본문

개발일지/React-Native

React Navigation - native-stack 뒤로가기 방지 오류

Seobe95 2024. 9. 11. 19:06

React Navigation의 native stack을 활용하여 네비게이션을 사용중이었는데, 공식문서에 나와있는 것처럼 뒤로가기 방지 설정을 해주었는데도 방지가 안되고 뒤로가기가 잘 되고 해당 에러를 뱉었다.

 

아무래도 e.preventDefault() 함수가 작동하지 않아 발생하는 것 같다.

 

The screen ... was removed natively but didn't get removed from JS state.
This can happen if the action was prevented in a 'beforeRemove' listener, which is not fully supported in native-stack.
Consider using 'gestureEnabled: false' to prevent back gesture and use a custom back button with 'headerLeft' option to override the native behavior.

 

검색을 해보니 native stack 말고 stack 으로 변경해야 뒤로가기 방지가 잘 된다는 말을 듣고 stack으로 변경 후 시도를 했을 때 뒤로가기 방지가 되었다.

 

다만, 기존의 native-stack에서 사용중이었던 화면전환 animation 옵션(fade)은 지원하지 않아 따로 기능을 변경하거나 추가적인 작업이 필요할 것 같다.

 

'개발일지 > React-Native' 카테고리의 다른 글

react-native-nmap 기능 추가하기  (0) 2022.04.26
나의 늦은 typescript 적응기  (0) 2022.04.26