Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom options disrupt animation when navigating between same routes #830

Open
ozio opened this issue Aug 7, 2023 · 0 comments
Open

Custom options disrupt animation when navigating between same routes #830

ozio opened this issue Aug 7, 2023 · 0 comments

Comments

@ozio
Copy link

ozio commented Aug 7, 2023

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

yarn

Summary

I'm encountering an issue with expo-router@2 when using custom screen options. The problem arises when navigating between identical routes, e.g. from /[id] to /[id].

Without custom screen options
r1

With custom screen options
r2

/index.js

export default function Page() {
  const router = useRouter();

  return (
    <View>
      <TouchableOpacity
        onPress={() => router.push({
          pathname: "/[id]",
          params: { id: Math.round(Math.random() * 1000) },
        })}
      >
        <Text>Go inside</Text>
      </TouchableOpacity>
    </View>
  );
}

/[id].js

export default function Page() {
  const router = useRouter();
  const { id } = useLocalSearchParams();

  return (
    <View>
      <TouchableOpacity
        onPress={() => router.push({
          pathname: "/[id]",
          params: { id: Math.round(Math.random() * 1000) },
        })}
      >
        <Text>Go deeper</Text>
      </TouchableOpacity>
      <View>
        <Text>{id}</Text>
      </View>
    </View>
  );
}

/_layout.js:

export default function Layout() {
  return (
    <Stack>
      {/* if you uncomment following tag it will break the default behavior: */}
      {/* <Stack.Screen
        name="[id]"
        options={{
          title: "title",
        }}
      /> */}
    </Stack>
  );
}

Minimal reproducible example

I can't create Expo Snack, because it only allows to create a Snack for SDK<=48, but expo-router@2 is only available in SDK 49, so I put a minimal reproducible example in this repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant