victorkvarghese / react-native-boilerplate

🚀 Type Based Architecture for developing React Native Apps using react, redux, sagas and hooks with auth flow
MIT License
600 stars 209 forks source link

Missing Nav Types #28

Closed dthomason closed 2 years ago

dthomason commented 3 years ago

Not really an issue I would say, just a couple types missing.

Adding these allows for typescript to recognize navigation and routes as well as avoid typescript not liking the options={homeOptions} object we're passing in.

Other than that I'd say this is the best boiler plate I've seen so far. Simple and to the point allowing a man to work quickly, great job!!

const AuthStack = createStackNavigator<AuthParamList>();
const AppStack = createStackNavigator<AppParamList>();

type AppParamList = {
  Home: undefined;
};

export type AppNavProps<T extends keyof AppParamList> = {
  navigation: StackNavigationProp<AppParamList, T>;
  route: RouteProp<AppParamList, T>;
};

type AuthParamList = {
  Login: undefined;
  ForgotPassword: undefined;
};

export type AuthNavProps<T extends keyof AuthParamList> = {
  navigation: StackNavigationProp<AuthParamList, T>;
  route: RouteProp<AuthParamList, T>;
};

interface HomeOptions {
  title: 'Home';
  headerTitleStyle: {
    fontWeight: 'bold';
  };
  headerRight: () => JSX.Element;
}

const homeOptions: HomeOptions = {
  title: 'Home',
  headerTitleStyle: {
    fontWeight: 'bold',
  },
  headerRight: () => <ThemeController />,
};
victorkvarghese commented 3 years ago

@dthomason sure will add them in examples. Didn't do it as it project specific.