Skip to content

Commit

Permalink
Merge pull request #155 from episerver/bugfix/AFORM-4388-Error-going-…
Browse files Browse the repository at this point in the history
…to-next-step

Add compatible for UseHistory of react-router v5
  • Loading branch information
epi-qang2 authored Sep 26, 2024
2 parents b330d44 + 4cc74dd commit 1fbeb3b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ coverage/
/samples/epiCloud/
/samples/musicfestival-frontend-react/build/
/samples/musicfestival-backend-dotnet/App_Data/

.env.local
appsettings.development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useNavigate, useLocation } from 'react-router-dom';

export const useHistoryCompatible = () => {
const navigate = useNavigate();
const location = useLocation();

return {
push: (path: any, state: any) => navigate(path, { state }),
replace: (path: any, state: any) => navigate(path, { replace: true, state }),
location: location,
goBack: () => navigate(-1),
goForward: () => navigate(1),
};
};
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { Form, FormContainerBlock, FormLogin } from '@episerver/forms-react';
import { FormCache, FormConstants, IdentityInfo, extractParams } from '@episerver/forms-sdk';
import { useEffect, useState } from 'react';
import { useNavigate, useLocation } from 'react-router-dom';
import { useFetch } from '../useFetch';
import { useHistoryCompatible } from '../hooks/useHistoryCompatible';
import SearchButton from '../components/SearchButton';
import { getImageUrl } from '../helpers/urlHelper';
import authService from '../authService';

type BuyTicketPageProps = {
content: any,
Expand All @@ -24,7 +21,7 @@ function BuyTicketPage({ content }: BuyTicketPageProps) {
} as IdentityInfo)
}, [formCache.get<string>(FormConstants.FormAccessToken)]);

const history = useNavigate()
const history = useHistoryCompatible()
return (
<>
{content &&
Expand Down

0 comments on commit 1fbeb3b

Please sign in to comment.