Skip to content

Commit

Permalink
fix: don't undefine tab on refresh context
Browse files Browse the repository at this point in the history
  • Loading branch information
NiiMiyo committed Oct 1, 2024
1 parent ac166d6 commit 0c0cbd1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/pages/Group/Group.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, useEffect, useState } from "react";
import { useContext, useEffect, useRef, useState } from "react";
import { Navigate, useLoaderData } from "react-router-dom";

import { GroupContext, GroupIntro, GroupTabRenderer, GroupTabs, fetchGroupPageData, type AvailableTabs, asTabAvailable, type GroupContextType, type GroupPageLoaderResponse, RefreshGroupOptions } from "@/pages/Group";
Expand All @@ -12,6 +12,8 @@ import GroupConfigModal from './GroupConfig/GroupConfigModal';
export function GroupPage() {
const page = useLoaderData() as GroupPageLoaderResponse;
const authContext = useContext(AuthContext);

const tabSave = useRef<AvailableTabs>();
const [context, setContext] = useState(makeContext(page));

useEffect(() => {
Expand Down Expand Up @@ -159,9 +161,10 @@ export function GroupPage() {
setContext({...this, editJob: j})
},

currentTab: undefined,
currentTab: tabSave.current,
setCurrentTab(t) {
setContext({ ...this, currentTab: t })
setContext({ ...this, currentTab: t });
tabSave.current = t;
},

refreshData: refreshGroupData,
Expand Down

0 comments on commit 0c0cbd1

Please sign in to comment.