Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatible for UseHistory of react-router v5 #155

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading