router icon indicating copy to clipboard operation
router copied to clipboard

Unable to render drawer page

Open xydian opened this issue 2 years ago • 2 comments

Which package manager are you using? (Yarn is recommended)

npm

Summary

I am unable to get drawer navigation to work with expo router.

The action 'REPLACE' with payload {"name":"dashboard"} was not handled by any navigator.

Do you have a screen named 'dashboard'?

This happens with the following strucutre

_layout.tsx

import { Drawer } from 'expo-router/drawer'

import { NavigationBar } from './components'

export const unstable_settings = {
  // Ensure any route can link back to `/`
  initialRouteName: 'index',
}

export default function Layout() {
  return (
    <Drawer
      screenOptions={{
        header: NavigationBar,
        drawerStyle: {
          width: 240,
        },
        drawerType: 'permanent',
      }}
    />
  )
}

dashboard.tsx

import React from 'react'
import { View } from 'react-native'

export default function Dashboard(){
   return (
      <View />
   )
}

index.tsx

import { Redirect } from 'expo-router'

import { ReactElement } from 'react'

export default function Prosumer(): ReactElement {
  return <Redirect href="./prosumer/dashboard" />
}

Minimal reproducible example

See above

xydian avatar May 23 '23 17:05 xydian

Okay i figured it out after reading this comment in another issue. It seems that push seems to be working but <Redirect /> uses replace internally and hence is not working. If I navigate directly to /dashboard (and not to the index file) using router.push it works. Gonna keep this issue open regardless because I think this is still something that should work.

xydian avatar May 23 '23 20:05 xydian

I'm having this same issue. I have a stack inside a drawer and I want to default redirect my root drawer index route to the nested stack. I am returning a redirect and also tried router.redirect to the route and it doesn't actually change the route.

zachkamran avatar Jun 05 '24 17:06 zachkamran