How to use withNavigation in react-native version 5
https://reactnavigation.org/docs/compatibility/
React Navigation
> Note: Before following this guide, make sure that you've followed the [Getting Started](getting-started.md) guide to setup React Navigation 5 in your app.
reactnavigation.org
다행히도, v5 이전의 API를 지원하는 패키지가 따로 있다.
If you were importing actions from react-navigation, you need to change them to import from @react-navigation/compat:
react-navigation에서 import 하던 것을
@react-navigation/compat 을 설치해 그대로 import 하면 된다!
- install
yarn add @react-navigation/compat
- Usage
import { withNavigation } from '@react-navigation/compat';
- 추가로, 다음과 같은 API를 지원한다. (v4 때 지원하던 API )
The library exports the following APIs:
Actions:
NavigationActions
StackActions
DrawerActions
SwitchActions
HOCs:
withNavigation
withNavigationFocus
Navigators:
createSwitchNavigator
Compatibility helpers
createCompatNavigatorFactory - Takes a navigator with the v5 API and returns a createXNavigator with the v4 API.
createCompatNavigationProp - Takes the v5 navigation object along with a route object and returns a v4 navigation object.
'Solve Problem > React Native' 카테고리의 다른 글
[React Native] NFC 태그 시 앱/어플 실행시키는 방법 (Android 위주) (10) | 2020.03.18 |
---|---|
[React/RN] useMutation react-apollo-hooks error (0) | 2020.03.13 |
React Native Boiler Plate NPM package (0) | 2020.03.11 |
[React Native] Bolier Plate 보일러 플레이트 코드 (0) | 2020.03.05 |
[React Native] react-native-maps 구글맵 (0) | 2020.03.04 |