@ahnseungchan/webviewkit 1.0.6 → 1.0.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.
|
@@ -13,21 +13,31 @@ export const useStackRouter = () => {
|
|
|
13
13
|
return context;
|
|
14
14
|
};
|
|
15
15
|
const StackRouter = ({ maxWidth = "600px", Activities = [], initialActivity, ActivitysLayout, }) => {
|
|
16
|
-
|
|
16
|
+
// 실제 URL과 동기화된 초기 경로 설정
|
|
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());
|
|
17
24
|
const [currentState, setCurrentState] = useState(history.getCurrentState());
|
|
18
25
|
const [isTransitioning, setIsTransitioning] = useState(false);
|
|
19
26
|
const [direction, setDirection] = useState(Direction.FORWARD);
|
|
20
27
|
const [visiblePages, setVisiblePages] = useState([]);
|
|
21
|
-
//
|
|
28
|
+
// 초기 페이지 설정 - 실제 URL 기반으로 동기화
|
|
22
29
|
useEffect(() => {
|
|
30
|
+
const initialPath = getInitialPath();
|
|
31
|
+
const initialActivityForPath = Activities.find((a) => a.path === initialPath) || initialActivity;
|
|
23
32
|
setVisiblePages([
|
|
24
33
|
{
|
|
25
|
-
path:
|
|
26
|
-
element:
|
|
34
|
+
path: initialPath,
|
|
35
|
+
element: initialActivityForPath.element,
|
|
27
36
|
isEntering: true,
|
|
28
37
|
},
|
|
29
38
|
]);
|
|
30
|
-
|
|
39
|
+
setCurrentPath(initialPath);
|
|
40
|
+
}, [initialActivity, Activities]);
|
|
31
41
|
// listen to history changes
|
|
32
42
|
useEffect(() => {
|
|
33
43
|
const removeListener = history.addListener((state) => {
|