Select " /> Select " /> Select "/>

Expo router.push works only when passing string directly

23 Views Asked by At

In my Expo app when I pass string directly to router.push() like below it works

<Button onPress={() => router.push("../chat/index")}>
    Select
</Button>

but when I pass string from props

interface Props {
    href: string
}

<Button onPress={() => router.push(href)}>
    Select
</Button>

I got the error

enter image description here

I also tried this

interface Props {
    href: string
}

<Button onPress={() => router.push({ pathname: href })}>
    Select
</Button>

but I got the same error

I am using

"expo": "~50.0.8",
"expo-router": "~3.4.8"
0

There are 0 best solutions below