skip to Main Content

i just updated from sdk 51 to sdk52 on my expo react native app.
Before the update i was trying to push in a route with according params like this:

onPress={() => router.push(../routes/workoutDetail?id=${workout.id})}

But now the parameter im trying to access in the workoutDetail is undefined

useEffect(() => { 
    const workoutId = route.params?.id; 
    if (workoutId) {
      fetchWorkoutDetails(workoutId);
    }
  }, [route.params?.id]);

I tried getting the parameters like this aswell:

const params = useLocalSearchParams();
  const { id = } = params;

but nothing works

I would appreciate any help πŸ™‚

2

Answers


  1. Have you tried passing the parameter like this?

    router.push({
        pathname: '../routes/workoutDetail',
        params: {
            id: workout.id
        }
    })

    Also, using ../routes may not be the best approach for defining the pathname. It’s better to use the global namespace"

    Login or Signup to reply.
  2. This problem was solved when I upgraded to Expo v52.0.7 and ran npx expo install –fix again.

    I think that the original update did not update @react-navigation/native from ^6.x to ^7.0.0, and this was fixed.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search