Feature/update dependency react router dom to v6.x (#340)
* Update dependency "react-router-dom" to v6.x Update to v6.11.2 * Update dependency "react-router-dom" to v6.x - Replace "Switch" with "Routes" * Update dependency "react-router-dom" to v6.x - Relative paths * Update dependency "react-router-dom" to v6.x - Nested routes * Update dependency "react-router-dom" to v6.x - Prevent route warnings - Route without an element causes a warning message. - Routes with non-matching Route causes a warning message. * Update dependency "react-router-dom" to v6.x - Replace "useHistory" with "useNavigate" * Update dependency "react-router-dom" to v6.x - Fix "Link" usage * Update dependency "react-router-dom" to v6.x - Overwrite "useParams" and "useLocations" typing For both functions it's the users fault if they are getting used incorrectly. It's inconvenient to always have to make sure the params exist (useParam) or to cast the return object to a specific type (useLocation) - "useParams": Make generic type non-optional - "useLocation": Add generic type * Update dependency "react-router-dom" to v6.x - Fix use-query-params provider
This commit is contained in:
@@ -14,7 +14,7 @@ import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
|
||||
import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import Typography from '@mui/material/Typography';
|
||||
import { useHistory, useLocation } from 'react-router-dom';
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
import Slide from '@mui/material/Slide';
|
||||
import Fade from '@mui/material/Fade';
|
||||
import Zoom from '@mui/material/Zoom';
|
||||
@@ -125,7 +125,7 @@ interface IProps {
|
||||
|
||||
export default function ReaderNavBar(props: IProps) {
|
||||
const { t } = useTranslation();
|
||||
const history = useHistory();
|
||||
const navigate = useNavigate();
|
||||
const backTo = useBackTo();
|
||||
const location = useLocation<{
|
||||
prevDrawerOpen?: boolean;
|
||||
@@ -188,9 +188,9 @@ export default function ReaderNavBar(props: IProps) {
|
||||
}, [handleScroll]); // handleScroll changes on every render
|
||||
|
||||
const handleClose = () => {
|
||||
if (backTo.back) history.goBack();
|
||||
else if (backTo.url) history.push(backTo.url);
|
||||
else history.push(`/manga/${manga.id}`);
|
||||
if (backTo.back) navigate(-1);
|
||||
else if (backTo.url) navigate(backTo.url);
|
||||
else navigate(`/manga/${manga.id}`);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -300,8 +300,8 @@ export default function ReaderNavBar(props: IProps) {
|
||||
disabled={disableChapterNavButtons || chapter.index <= 1}
|
||||
onClick={() =>
|
||||
openNextChapter(ChapterOffset.PREV, (prevChapterIndex) => {
|
||||
history.replace({
|
||||
pathname: `/manga/${manga.id}/chapter/${prevChapterIndex}`,
|
||||
navigate(`/manga/${manga.id}/chapter/${prevChapterIndex}`, {
|
||||
replace: true,
|
||||
state: {
|
||||
prevDrawerOpen: drawerOpen,
|
||||
prevSettingsCollapseOpen: settingsCollapseOpen,
|
||||
@@ -322,8 +322,8 @@ export default function ReaderNavBar(props: IProps) {
|
||||
value={chapter.index >= 1 ? chapter.index : ''}
|
||||
displayEmpty
|
||||
onChange={({ target: { value: selectedChapter } }) => {
|
||||
history.replace({
|
||||
pathname: `/manga/${manga.id}/chapter/${selectedChapter}`,
|
||||
navigate(`/manga/${manga.id}/chapter/${selectedChapter}`, {
|
||||
replace: true,
|
||||
state: {
|
||||
prevDrawerOpen: drawerOpen,
|
||||
prevSettingsCollapseOpen: settingsCollapseOpen,
|
||||
@@ -350,8 +350,8 @@ export default function ReaderNavBar(props: IProps) {
|
||||
}
|
||||
onClick={() => {
|
||||
openNextChapter(ChapterOffset.NEXT, (nextChapterIndex) =>
|
||||
history.replace({
|
||||
pathname: `/manga/${manga.id}/chapter/${nextChapterIndex}`,
|
||||
navigate(`/manga/${manga.id}/chapter/${nextChapterIndex}`, {
|
||||
replace: true,
|
||||
state: {
|
||||
prevDrawerOpen: drawerOpen,
|
||||
prevSettingsCollapseOpen: settingsCollapseOpen,
|
||||
|
||||
Reference in New Issue
Block a user