@rdyl/react-native-navigator-connect 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/hooks.js CHANGED
@@ -13,7 +13,9 @@ const useNavigator = () => {
13
13
  if (opt) {
14
14
  return opt.option;
15
15
  }
16
+ return {};
16
17
  }, [route.name, findOption]);
18
+ const canGoBack = (0, react_1.useMemo)(() => navigation.canGoBack(), [navigation, route.name]);
17
19
  const push = (0, react_1.useCallback)((name, params) => {
18
20
  navigation.dispatch(native_1.CommonActions.navigate({
19
21
  name,
@@ -21,13 +23,10 @@ const useNavigator = () => {
21
23
  }));
22
24
  }, [navigation]);
23
25
  const back = (0, react_1.useCallback)(() => {
24
- if (navigation.canGoBack()) {
26
+ if (canGoBack) {
25
27
  navigation.dispatch(native_1.CommonActions.goBack());
26
28
  }
27
- else {
28
- throw Error();
29
- }
30
- }, [navigation]);
29
+ }, [navigation, canGoBack]);
31
30
  const redirect = (0, react_1.useCallback)((name, params) => {
32
31
  const opt = findOption(name);
33
32
  if (opt) {
@@ -42,7 +41,7 @@ const useNavigator = () => {
42
41
  const onParams = (0, react_1.useCallback)((params = {}) => {
43
42
  navigation.dispatch(Object.assign(Object.assign({}, native_1.CommonActions.setParams(params)), { source: route.key }));
44
43
  }, [navigation, route]);
45
- return Object.assign(Object.assign({}, route), { option,
44
+ return Object.assign(Object.assign(Object.assign({}, route), option), { canGoBack,
46
45
  push,
47
46
  back,
48
47
  redirect,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rdyl/react-native-navigator-connect",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./types/index.d.ts",
6
6
  "license": "MIT",
package/types/hooks.d.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  export declare const useNavigator: () => {
2
- option: NavigatorOption | undefined;
2
+ canGoBack: boolean;
3
3
  push: (name: string, params?: QueryParams) => void;
4
4
  back: () => void;
5
5
  redirect: (name: string, params?: QueryParams) => void;
6
6
  onParams: (params?: QueryParams) => void;
7
- key: string;
8
7
  name: string;
8
+ meta?: NavigatorOptionMeta;
9
+ isPublic?: boolean;
10
+ component: React.ComponentType<any>;
11
+ key: string;
9
12
  path?: string;
10
13
  params?: Readonly<object | undefined>;
11
14
  };