Skip to content

Commit

Permalink
Slutt å mellomlagre context i localStorage
Browse files Browse the repository at this point in the history
Det brekker dekoratøren i noen tilfeller ved å overstyre verdien
  • Loading branch information
LudvigHz committed Oct 3, 2024
1 parent 5cb2762 commit 5cc3086
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/context/valgtenhet-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ interface ValgtEnhetState {
}

const ValgtEnhetContext = React.createContext<ValgtEnhetState | undefined>(undefined);
const valgtEnhetKey = 'modia-valgt-enhet';

export function ValgtEnhetProvider(props: { children: React.ReactNode }) {
const isMounted = useIsMounted();
const [enhetId, setEnhetId] = React.useState(window.localStorage.getItem(valgtEnhetKey) ?? '');
const [enhetId, setEnhetId] = React.useState('');
const updateEnhet = React.useCallback(
(enhetId: string) => {
if (isMounted.current) {
setEnhetId(enhetId);
window.localStorage.setItem(valgtEnhetKey, enhetId);
}
},
[setEnhetId, isMounted]
Expand Down

0 comments on commit 5cc3086

Please sign in to comment.