expo / router

[ARCHIVE]: Expo Router has moved to expo/expo -- The File-based router for universal React Native apps

Home Page:https://docs.expo.dev/routing/introduction/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expo Router V2 breaks when calling hook on destination page

jstdk opened this issue · comments

commented

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

npm (issue also occurs with Yarn)

Summary

I can only route to other pages if it is static (meaning, no dynamic stuff happens on the destination page). The moment I add any hook into the destination page, routing stops (Unmatched Route). It fails with both dynamic and static aliases. When I import, it recognizes the imported file. The routing succeeds if I import and comment out the hook call. The issue is the hook call.

Minimal reproducible example

index.tsx

import { Link } from "expo-router";
import React from "react";
import { View } from "react-native";

export default function Page() {
    return (
        <View>
            <Link href="/bot">See bots</Link>
        </View>
    );
}

This works:

bot.tsx

import React from "react";
import { Text, View } from "react-native";

export default function Page() {
    return (
        <View>
            <Text>Hell yeah</Text>
        </View>
    );
}

This does NOT work

bot.tsx

import React from "react";
import { Text, View } from "react-native";
import { retrieveBots } from "@/controllers/bots";

export default function Page() {
    let response: any = retrieveBots(1, 'blabla'); 
    console.log(response)

    return (
        <View >
            <Text>Hell no</Text>
            </View>
    );
}

This worked like a charm in SDK48 with router v1.5

commented

Will close for now. There are many things going wrong on Web, but this issue is related to Supabase I suspect.

This is not a valid reproducible example, e.g. I cannot reproduce the behavior given the code and info you provided.

@EvanBacon, I will leave a reproducible example shortly. I experienced the same issue as well with expo-auth-session in combination with expo-router v2

Facing same issue with Clerk Auth.

@Rajvira10 Telling us you have an issue isn't enough information for us to fix it for you. If you'd like your issue resolved, please create a new issue with a reproducible example