@sigmela/router 0.1.1 → 0.1.3
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/lib/module/Router.js
CHANGED
|
@@ -322,6 +322,9 @@ export class Router {
|
|
|
322
322
|
} = this.parsePath(path);
|
|
323
323
|
const matched = this.matchRoute(pathname);
|
|
324
324
|
if (!matched) {
|
|
325
|
+
if (__DEV__) {
|
|
326
|
+
throw new Error(`Route not found: "${pathname}"`);
|
|
327
|
+
}
|
|
325
328
|
return;
|
|
326
329
|
}
|
|
327
330
|
if (matched.scope === 'tab' && this.tabBar && matched.tabIndex !== undefined) {
|
|
@@ -783,6 +786,9 @@ export class Router {
|
|
|
783
786
|
} = this.parsePath(url);
|
|
784
787
|
const deepest = this.matchRoute(pathname);
|
|
785
788
|
if (!deepest) {
|
|
789
|
+
if (__DEV__) {
|
|
790
|
+
throw new Error(`Route not found: "${pathname}"`);
|
|
791
|
+
}
|
|
786
792
|
this.seedInitialHistory();
|
|
787
793
|
return;
|
|
788
794
|
}
|
|
@@ -6,11 +6,13 @@ export class TabBar {
|
|
|
6
6
|
screens = {};
|
|
7
7
|
stacks = {};
|
|
8
8
|
listeners = new Set();
|
|
9
|
-
constructor(
|
|
9
|
+
constructor(options = {}) {
|
|
10
10
|
this.state = {
|
|
11
11
|
tabs: [],
|
|
12
|
-
index: 0,
|
|
13
|
-
config
|
|
12
|
+
index: options.initialIndex ?? 0,
|
|
13
|
+
config: {
|
|
14
|
+
component: options.component
|
|
15
|
+
}
|
|
14
16
|
};
|
|
15
17
|
}
|
|
16
18
|
addTab(tab) {
|
|
@@ -26,12 +26,17 @@ type TabBarConfig = Omit<InternalTabItem, 'tabKey' | 'key'> & {
|
|
|
26
26
|
screen?: React.ComponentType<any>;
|
|
27
27
|
component?: ComponentType<TabBarProps>;
|
|
28
28
|
};
|
|
29
|
+
type TabBarOptions = {
|
|
30
|
+
component?: ComponentType<TabBarProps>;
|
|
31
|
+
config?: TabBarConfig;
|
|
32
|
+
initialIndex?: number;
|
|
33
|
+
};
|
|
29
34
|
export declare class TabBar {
|
|
30
35
|
screens: Record<string, React.ComponentType<any>>;
|
|
31
36
|
stacks: Record<string, NavigationStack>;
|
|
32
37
|
private listeners;
|
|
33
38
|
private state;
|
|
34
|
-
constructor(
|
|
39
|
+
constructor(options?: TabBarOptions);
|
|
35
40
|
addTab(tab: Omit<TabBarConfig, 'tabKey'> & {
|
|
36
41
|
key: string;
|
|
37
42
|
}): TabBar;
|