Skip to content

Commit eda14f2

Browse files
committed
dispatch redux action LOCATION_CHANGE when redux-router location changes
1 parent c63452e commit eda14f2

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

handlereg.web.frontend/src/main/frontend/src/actiontypes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ export const VELG_FAVORITTBUTIKK = createAction('VELG_FAVORITTBUTIKK');
1414
export const VIS_KVITTERING = createAction('VIS_KVITTERING');
1515

1616
export const SET_BASENAME = createAction('SET_BASENAME');
17+
18+
export const LOCATION_CHANGE = createAction('LOCATION_CHANGE');

handlereg.web.frontend/src/main/frontend/src/components/Home.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React from 'react';
2-
import { Link } from 'react-router';
1+
import React, { useEffect } from 'react';
2+
import { Link, useLocation } from 'react-router';
33
import { useSelector, useDispatch } from 'react-redux';
44
import { useSwipeable } from 'react-swipeable';
55
import {
@@ -12,6 +12,7 @@ import {
1212
BELOP_ENDRE,
1313
HOME_BUTIKKNAVN_ENDRE,
1414
DATO_ENDRE,
15+
LOCATION_CHANGE,
1516
} from '../actiontypes';
1617
import Kvittering from './Kvittering';
1718
import ChevronRight from './bootstrap/ChevronRight';
@@ -29,6 +30,8 @@ export default function Home() {
2930
const handledato = handletidspunkt.split('T')[0];
3031
const belop = useSelector(state => state.belop).toString();
3132
const dispatch = useDispatch();
33+
const location = useLocation();
34+
useEffect(() => {dispatch(LOCATION_CHANGE(location))}, [location]);
3235
const onNextPageClicked = async () => fetchNextPage();
3336
const onRegistrerHandlingClicked = async () => {
3437
await postNyhandling({ storeId, belop, handletidspunkt, username })

0 commit comments

Comments
 (0)