DrawerActions リファレンス
DrawerActions
はドロアーベースのナビゲーターに固有のアクションを生成するためのメソッドを含むオブジェクトです。そのメソッドはCommonActionsで使用可能なアクションを拡張します。
サポートされているアクションを以下に示します
openDrawer
openDrawer
アクションはドロアーペインを開くために使用できます。
import { DrawerActions } from '@react-navigation/native';
navigation.dispatch(DrawerActions.openDrawer());
closeDrawer
closeDrawer
アクションはドロアーペインを閉じるために使用できます。
import { DrawerActions } from '@react-navigation/native';
navigation.dispatch(DrawerActions.closeDrawer());
toggleDrawer
toggleDrawer
アクションは閉じていた場合はドロアーペインを開き、開いていた場合は閉じるために使用できます。
import { DrawerActions } from '@react-navigation/native';
navigation.dispatch(DrawerActions.toggleDrawer());
jumpTo
jumpTo
アクションはドロアーナビゲーターの既存のルートにジャンプするために使用できます。
name
- string - ジャンプ先のルートの名前です。params
- object - 宛先ルートに渡す画面のパラメータです。
import { DrawerActions } from '@react-navigation/native';
const jumpToAction = DrawerActions.jumpTo('Profile', { name: 'Satya' });
navigation.dispatch(jumpToAction);