@tker-react/layout 0.2.10 → 0.2.11
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/index.mjs +8 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -359,13 +359,19 @@ function LayoutContent({ children }) {
|
|
|
359
359
|
navigate
|
|
360
360
|
} = useLayoutContext();
|
|
361
361
|
const isTopMenu = layoutMode === "top-menu";
|
|
362
|
-
const [tabData, setTabData] = useState([]);
|
|
363
|
-
const [activeTab, setActiveTab] = useState("");
|
|
364
362
|
const menuDataRef = useRef(menuData);
|
|
365
363
|
menuDataRef.current = menuData;
|
|
364
|
+
const initialTab = activePath && activePath !== "/" ? openTabInData([], activePath, { homePath, maxTabs, menuData }) : [];
|
|
365
|
+
const [tabData, setTabData] = useState(() => initialTab);
|
|
366
|
+
const [activeTab, setActiveTab] = useState(() => initialTab.length > 0 ? activePath : "");
|
|
366
367
|
const activeTabRef = useRef(activeTab);
|
|
367
368
|
activeTabRef.current = activeTab;
|
|
369
|
+
const isFirstRender = useRef(true);
|
|
368
370
|
useEffect(() => {
|
|
371
|
+
if (isFirstRender.current) {
|
|
372
|
+
isFirstRender.current = false;
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
369
375
|
if (!activePath || activePath === "/") return;
|
|
370
376
|
setTabData((prev) => {
|
|
371
377
|
const exists = prev.find((t) => t.path === activePath);
|