nandorojo / solito

🧍‍♂️ React Native + Next.js, unified.
https://solito.dev
MIT License
3.54k stars 181 forks source link

useParam doesn't return expected value #152

Closed hlynurstef closed 2 years ago

hlynurstef commented 2 years ago

I just updated to v.1.0.10 and I noticed that useParam is not giving me the expected value in React Native when I use the following code:

Login screen that calls router.push:

import { useRouter } from "solito/router";

export const LoginScreen: React.FC => {
  const router = useRouter();

  const signIn = useCallback(async () => {
    router.push(`/home/foobar`);
  }, [router]);

  return <Button onPress={signIn}>Login</Button>;
}

Home screen that gets id using useParam:

import { createParam } from "solito";

const { useParam } = createParam<{ id: string }>();

export const HomeScreen: React.FC => {
  const [id] = useParam("id");

  return <Text>{`User ID: ${id}`}</Text>
}

solito

In version 0.0.29 useParam returns "foobar" In version 1.0.10 useParam returns {id: "foobar"}

Is this expected or a bug? I couldn't find any reference to changes to the API in the release notes or in the docs.

nandorojo commented 2 years ago

Oh wow, that’s not good. I’m pushing a fix now. Sorry about that.

nandorojo commented 2 years ago

Should be fixed in 1.0.11. Can you let me know?

hlynurstef commented 2 years ago

Confirmed fixed in 1.0.11, thanks for the quick fix!

solito2

nandorojo commented 2 years ago

great!