Skip to content

Commit

Permalink
feat: window 객체를 노드서버에서 인식하지 못하는 상황해결
Browse files Browse the repository at this point in the history
  • Loading branch information
MuteAim committed Feb 18, 2025
1 parent 777f3f8 commit 31438a4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/app/_components/contexts/activeSectionContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ const ActiveSectionContext = createContext({
setActiveSectionId: () => {},
});

const initialValue =
typeof window !== "undefined" ? window.location.hash.replace("#", "") : "";

export const useActiveSectionContext = () => {
const { activeSectionId, setActiveSectionId } =
useContext(ActiveSectionContext);
return { activeSectionId, setActiveSectionId };
};

export const ActiveSectionProvider = ({ children }) => {
const [activeSectionId, setActiveSectionId] = useState(
window.location.hash.replace("#", "")
);
const [activeSectionId, setActiveSectionId] = useState(initialValue);

const handleSetActiveSectionId = (id) => {
setActiveSectionId(id);
Expand Down

0 comments on commit 31438a4

Please sign in to comment.