kanzitelli / expo-starter

🦥 Expo Starter - Powered by Expo SDK, Navio (React Navigation), RN UI lib, MMKV, Mobx, Reanimated 2, Dark Mode, Localization, and much more.
https://starters.dev
403 stars 54 forks source link

Params doesn't seem to work. #44

Closed nick-potts closed 1 year ago

nick-potts commented 1 year ago

When pushing with params, the params never seem to be available. For instance using this repo, when changing these params:

https://github.com/kanzitelli/expo-starter/blob/11df29781105bf3b0a2c1ebe7aaad19b683cbc4c/src/components/sections/NavioSection.tsx#L15

You'd expect the type value to change here:

https://github.com/kanzitelli/expo-starter/blob/11df29781105bf3b0a2c1ebe7aaad19b683cbc4c/src/screens/_screen-sample.tsx#L16

However it never changes, and simply changing it to a props and logging it shows that its receiving a far different object to what is expected (a route object if I'm not mistaken).

kanzitelli commented 1 year ago

Hi @nick-potts! Thank you for opening the issue for this. Yes, you are right, there is a mistake in _screen-sample.tsx as the params that you pass with navio.push can be only accessible through React Navigation's useRoute() hook. So the example should look like this:

export type Params = {
  type?: 'push';
};

export const Example: NavioScreen = observer(() => {
  useAppearance(); // for Dark Mode
  const navigation = useNavigation();
  const {params: _p} = useRoute();
  const params = _p as Params;
  const {t, navio} = useServices();
  // const {ui} = useStores();

  console.log(params?.type);

  // ...
}

However, in the future it would be cool to have params accessible directly through component's props 🤔 I might consider implementing something like that.

Let it me knows how it goes!

kanzitelli commented 1 year ago

Closed by #45