From 57cfb9a5129d374201ccd3d897e8a8934f578e98 Mon Sep 17 00:00:00 2001 From: "satyajit.happy" Date: Mon, 10 Jun 2019 04:43:42 +0200 Subject: [PATCH] feat: support options --- example/StackNavigator.tsx | 16 ++++++++++++++++ example/index.tsx | 6 +++--- src/Screen.tsx | 4 +++- src/types.tsx | 7 ++++++- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/example/StackNavigator.tsx b/example/StackNavigator.tsx index be176c60..59974c39 100644 --- a/example/StackNavigator.tsx +++ b/example/StackNavigator.tsx @@ -106,6 +106,22 @@ export default function StackNavigator(props: Props) { {descriptors[route.key].render()} ))} +
+ { + descriptors[navigation.state.routes[navigation.state.index].key] + .options.title + } +
); } diff --git a/example/index.tsx b/example/index.tsx index 9863501d..6e513b9f 100644 --- a/example/index.tsx +++ b/example/index.tsx @@ -89,9 +89,9 @@ function App() { return ( - - - + + + {() => ( diff --git a/src/Screen.tsx b/src/Screen.tsx index b967c6d6..e4c4c62a 100644 --- a/src/Screen.tsx +++ b/src/Screen.tsx @@ -1,6 +1,8 @@ +import { Options } from './types'; + export type Props = { name: string; - options?: object; + options?: Options; } & ( | { component: React.ComponentType } | { children: (props: any) => React.ReactNode }); diff --git a/src/types.tsx b/src/types.tsx index bae1b43f..59dec4ad 100644 --- a/src/types.tsx +++ b/src/types.tsx @@ -36,7 +36,12 @@ export type NavigationProp< state: Route | NavigationState; }; -export type Descriptor = { +export type Descriptor = { render(): React.ReactNode; options: Options; }; + +export type Options = { + title?: string; + [key: string]: any; +};