-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #155 from episerver/bugfix/AFORM-4388-Error-going-…
…to-next-step Add compatible for UseHistory of react-router v5
- Loading branch information
Showing
3 changed files
with
19 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
samples/musicfestival-frontend-react/src/hooks/useHistoryCompatible.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters