Skip to content

Commit

Permalink
Omgjør komponent til hook
Browse files Browse the repository at this point in the history
  • Loading branch information
hanneolsen committed Jan 13, 2025
1 parent 44c5f39 commit 38d2296
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/frontend/komponenter/Fagsak/FagsakContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Dokumentutsending from './Dokumentutsending/Dokumentutsending';
import JournalpostListe from './journalposter/JournalpostListe';
import Personlinje from './Personlinje/Personlinje';
import Saksoversikt from './Saksoversikt/Saksoversikt';
import { ScrollTilAnker } from './ScrollTilAnker';
import { useScrollTilAnker } from './useScrollTilAnker';
import { HentOgSettBehandlingProvider } from '../../context/behandlingContext/HentOgSettBehandlingContext';
import { DokumentutsendingProvider } from '../../context/DokumentutsendingContext';
import { useFagsakContext } from '../../context/Fagsak/FagsakContext';
Expand All @@ -24,6 +24,7 @@ const HovedInnhold = styled.div`

const FagsakContainer: React.FunctionComponent = () => {
const { fagsakId } = useSakOgBehandlingParams();
useScrollTilAnker();

const { bruker: brukerRessurs, minimalFagsak, hentMinimalFagsak } = useFagsakContext();

Expand Down Expand Up @@ -114,7 +115,6 @@ const FagsakContainer: React.FunctionComponent = () => {
}
/>
</Routes>
<ScrollTilAnker />
</HovedInnhold>
);
case RessursStatus.FEILET:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useRef } from 'react';

import { useLocation } from 'react-router';

export function ScrollTilAnker() {
export function useScrollTilAnker() {
const location = useLocation();
const lastHash = useRef('');

Expand Down Expand Up @@ -32,6 +32,4 @@ export function ScrollTilAnker() {
scrollTilHash();
}, 500); // For å gi UIet tid til å rendres før vi finner og scroller til elementet
}, []);

return null;
}

0 comments on commit 38d2296

Please sign in to comment.