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

useParam doesn't return expected value #152

Closed
hlynurstef opened this issue Sep 11, 2022 · 4 comments
Closed

useParam doesn't return expected value #152

hlynurstef opened this issue Sep 11, 2022 · 4 comments

Comments

@hlynurstef
Copy link

hlynurstef commented Sep 11, 2022

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
Copy link
Owner

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

@nandorojo
Copy link
Owner

nandorojo commented Sep 11, 2022

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

@hlynurstef
Copy link
Author

hlynurstef commented Sep 11, 2022

Confirmed fixed in 1.0.11, thanks for the quick fix!

solito2

@nandorojo
Copy link
Owner

great!

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

2 participants