メインコンテンツに移動
バージョン: 6.x

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);