How to use withNavigation in react-native version 5
https://reactnavigation.org/docs/compatibility/
다행히도, 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.
'Develop > React Native' 카테고리의 다른 글
[React Native] run-android 되지 않을 때 / Could not compile settings file /JDK 문제 (2) | 2020.03.17 |
---|---|
[React/RN] useMutation react-apollo-hooks error (0) | 2020.03.13 |
React native paper (0) | 2020.03.12 |
React Native Boiler Plate NPM package (0) | 2020.03.11 |
[React Native] react-native-push-notification local notification 안드로이드 알람이 멈추지 않을 때 (0) | 2020.03.05 |