Expo router Drawer onOpen

I’m trying to figuring out how to have a callback when the Drawer has been opened, or closed. I simply want to call onOpen when the drawer gets opened. How can I achieve that?

This is my _layout.tsx code:


import { Drawer } from "expo-router/drawer";

export default function DrawerLayout() {
	const screens = [];

	const onOpen = () => {
		console.log("Drawer opened");
	};

	return (
		<Drawer>
			{screens.map((screen) => (
				<Drawer.Screen />
			))}
		</Drawer>
	);
}

image

I am also using expo router and this is works:

import { useDrawerStatus } from '@react-navigation/drawer';

// ...

const isDrawerOpen = useDrawerStatus() === 'open';

source: React Navigation

can u try like this ?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.