@ahnseungchan/webviewkit 1.0.7 → 1.0.8
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.
|
@@ -13,31 +13,21 @@ export const useStackRouter = () => {
|
|
|
13
13
|
return context;
|
|
14
14
|
};
|
|
15
15
|
const StackRouter = ({ maxWidth = "600px", Activities = [], initialActivity, ActivitysLayout, }) => {
|
|
16
|
-
|
|
17
|
-
const getInitialPath = () => {
|
|
18
|
-
const currentUrlPath = window.location.pathname;
|
|
19
|
-
// Activities에서 현재 URL에 해당하는 액티비티가 있는지 확인
|
|
20
|
-
const matchingActivity = Activities.find((a) => a.path === currentUrlPath);
|
|
21
|
-
return matchingActivity ? currentUrlPath : initialActivity.path;
|
|
22
|
-
};
|
|
23
|
-
const [currentPath, setCurrentPath] = useState(getInitialPath());
|
|
16
|
+
const [currentPath, setCurrentPath] = useState(history.getCurrentState().path);
|
|
24
17
|
const [currentState, setCurrentState] = useState(history.getCurrentState());
|
|
25
18
|
const [isTransitioning, setIsTransitioning] = useState(false);
|
|
26
19
|
const [direction, setDirection] = useState(Direction.FORWARD);
|
|
27
20
|
const [visiblePages, setVisiblePages] = useState([]);
|
|
28
|
-
//
|
|
21
|
+
// initialize visible pages
|
|
29
22
|
useEffect(() => {
|
|
30
|
-
const initialPath = getInitialPath();
|
|
31
|
-
const initialActivityForPath = Activities.find((a) => a.path === initialPath) || initialActivity;
|
|
32
23
|
setVisiblePages([
|
|
33
24
|
{
|
|
34
|
-
path:
|
|
35
|
-
element:
|
|
25
|
+
path: initialActivity.path,
|
|
26
|
+
element: initialActivity.element,
|
|
36
27
|
isEntering: true,
|
|
37
28
|
},
|
|
38
29
|
]);
|
|
39
|
-
|
|
40
|
-
}, [initialActivity, Activities]);
|
|
30
|
+
}, [initialActivity]);
|
|
41
31
|
// listen to history changes
|
|
42
32
|
useEffect(() => {
|
|
43
33
|
const removeListener = history.addListener((state) => {
|