chore(deps): update react router from v5 to v6 (#280)
* chore(deps): update react router from v5 to v6 * fix: correctly choose navigate target if there is no history
This commit is contained in:
@@ -3,7 +3,7 @@ import { Form, Formik } from 'formik'
|
||||
import { useSnackbar } from 'notistack'
|
||||
import { ReactElement, useContext, useState } from 'react'
|
||||
import { Check, X } from 'react-feather'
|
||||
import { useHistory } from 'react-router'
|
||||
import { useNavigate } from 'react-router'
|
||||
import { DocumentationText } from '../../components/DocumentationText'
|
||||
import ExpandableListItemActions from '../../components/ExpandableListItemActions'
|
||||
import ExpandableListItemKey from '../../components/ExpandableListItemKey'
|
||||
@@ -34,7 +34,7 @@ export default function CreateNewFeed(): ReactElement {
|
||||
const [loading, setLoading] = useState(false)
|
||||
const { enqueueSnackbar } = useSnackbar()
|
||||
|
||||
const history = useHistory()
|
||||
const navigate = useNavigate()
|
||||
|
||||
async function onSubmit(values: FormValues) {
|
||||
setLoading(true)
|
||||
@@ -65,12 +65,12 @@ export default function CreateNewFeed(): ReactElement {
|
||||
const identity = await convertWalletToIdentity(wallet, values.type, values.identityName, values.password)
|
||||
persistIdentity(identities, identity)
|
||||
setIdentities(identities)
|
||||
history.push(ROUTES.FEEDS)
|
||||
navigate(ROUTES.FEEDS)
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
history.goBack()
|
||||
navigate(-1)
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as swarmCid from '@ethersphere/swarm-cid'
|
||||
import { Box } from '@material-ui/core'
|
||||
import { ReactElement, useContext, useEffect, useState } from 'react'
|
||||
import { X } from 'react-feather'
|
||||
import { RouteComponentProps, useHistory } from 'react-router-dom'
|
||||
import { useParams, useNavigate } from 'react-router-dom'
|
||||
import { DocumentationText } from '../../components/DocumentationText'
|
||||
import ExpandableListItemActions from '../../components/ExpandableListItemActions'
|
||||
import ExpandableListItemKey from '../../components/ExpandableListItemKey'
|
||||
@@ -15,20 +15,16 @@ import { Context as SettingsContext } from '../../providers/Settings'
|
||||
import { ROUTES } from '../../routes'
|
||||
import { UploadArea } from '../files/UploadArea'
|
||||
|
||||
interface MatchParams {
|
||||
uuid: string
|
||||
}
|
||||
|
||||
export function FeedSubpage(props: RouteComponentProps<MatchParams>): ReactElement {
|
||||
export function FeedSubpage(): ReactElement {
|
||||
const { identities } = useContext(IdentityContext)
|
||||
const { uuid } = useParams()
|
||||
const { beeApi } = useContext(SettingsContext)
|
||||
const { status } = useContext(BeeContext)
|
||||
|
||||
const history = useHistory()
|
||||
const navigate = useNavigate()
|
||||
|
||||
const [available, setAvailable] = useState(false)
|
||||
|
||||
const uuid = props.match.params.uuid
|
||||
const identity = identities.find(x => x.uuid === uuid)
|
||||
|
||||
useEffect(() => {
|
||||
@@ -44,13 +40,13 @@ export function FeedSubpage(props: RouteComponentProps<MatchParams>): ReactEleme
|
||||
}, [beeApi, uuid, identity])
|
||||
|
||||
if (!identity || !status.all) {
|
||||
history.replace(ROUTES.FEEDS)
|
||||
navigate(ROUTES.FEEDS, { replace: true })
|
||||
|
||||
return <></>
|
||||
}
|
||||
|
||||
function onClose() {
|
||||
history.push(ROUTES.FEEDS)
|
||||
navigate(ROUTES.FEEDS)
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Box, Grid, Typography } from '@material-ui/core'
|
||||
import { useSnackbar } from 'notistack'
|
||||
import { ReactElement, useContext, useEffect, useState } from 'react'
|
||||
import { Bookmark, X } from 'react-feather'
|
||||
import { RouteComponentProps, useHistory } from 'react-router'
|
||||
import { useParams, useNavigate } from 'react-router'
|
||||
import ExpandableListItemActions from '../../components/ExpandableListItemActions'
|
||||
import { HistoryHeader } from '../../components/HistoryHeader'
|
||||
import { SwarmButton } from '../../components/SwarmButton'
|
||||
@@ -16,15 +16,12 @@ import { ROUTES } from '../../routes'
|
||||
import { persistIdentity, updateFeed } from '../../utils/identity'
|
||||
import { FeedPasswordDialog } from './FeedPasswordDialog'
|
||||
|
||||
interface MatchParams {
|
||||
hash: string
|
||||
}
|
||||
|
||||
export default function UpdateFeed(props: RouteComponentProps<MatchParams>): ReactElement {
|
||||
export default function UpdateFeed(): ReactElement {
|
||||
const { identities, setIdentities } = useContext(IdentityContext)
|
||||
const { beeApi, beeDebugApi } = useContext(SettingsContext)
|
||||
const { stamps, refresh } = useContext(StampContext)
|
||||
const { status } = useContext(BeeContext)
|
||||
const { hash } = useParams()
|
||||
|
||||
const [selectedStamp, setSelectedStamp] = useState<string | null>(null)
|
||||
const [selectedIdentity, setSelectedIdentity] = useState<Identity | null>(null)
|
||||
@@ -32,7 +29,7 @@ export default function UpdateFeed(props: RouteComponentProps<MatchParams>): Rea
|
||||
const { enqueueSnackbar } = useSnackbar()
|
||||
const [showPasswordPrompt, setShowPasswordPrompt] = useState(false)
|
||||
|
||||
const history = useHistory()
|
||||
const navigate = useNavigate()
|
||||
|
||||
useEffect(() => {
|
||||
refresh()
|
||||
@@ -50,7 +47,7 @@ export default function UpdateFeed(props: RouteComponentProps<MatchParams>): Rea
|
||||
}
|
||||
|
||||
function onCancel() {
|
||||
history.goBack()
|
||||
navigate(-1)
|
||||
}
|
||||
|
||||
function onBeginUpdatingFeed() {
|
||||
@@ -76,10 +73,10 @@ export default function UpdateFeed(props: RouteComponentProps<MatchParams>): Rea
|
||||
}
|
||||
|
||||
try {
|
||||
await updateFeed(beeApi, identity, props.match.params.hash, selectedStamp, password as string)
|
||||
await updateFeed(beeApi, identity, hash!, selectedStamp, password as string) // eslint-disable-line
|
||||
persistIdentity(identities, identity)
|
||||
setIdentities([...identities])
|
||||
history.push(ROUTES.FEEDS_PAGE.replace(':uuid', identity.uuid))
|
||||
navigate(ROUTES.FEEDS_PAGE.replace(':uuid', identity.uuid))
|
||||
} catch (error: unknown) {
|
||||
setLoading(false)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Box, Typography } from '@material-ui/core'
|
||||
import { ReactElement, useContext, useState } from 'react'
|
||||
import { Download, Info, PlusSquare, Trash } from 'react-feather'
|
||||
import { useHistory } from 'react-router'
|
||||
import { useNavigate } from 'react-router'
|
||||
import ExpandableList from '../../components/ExpandableList'
|
||||
import ExpandableListItem from '../../components/ExpandableListItem'
|
||||
import ExpandableListItemActions from '../../components/ExpandableListItemActions'
|
||||
@@ -20,7 +20,7 @@ export default function Feeds(): ReactElement {
|
||||
const { identities, setIdentities } = useContext(IdentityContext)
|
||||
const { status } = useContext(BeeContext)
|
||||
|
||||
const history = useHistory()
|
||||
const navigate = useNavigate()
|
||||
|
||||
const [selectedIdentity, setSelectedIdentity] = useState<Identity | null>(null)
|
||||
const [showImport, setShowImport] = useState(false)
|
||||
@@ -28,11 +28,11 @@ export default function Feeds(): ReactElement {
|
||||
const [showDelete, setShowDelete] = useState(false)
|
||||
|
||||
function createNewFeed() {
|
||||
return history.push(ROUTES.FEEDS_NEW)
|
||||
return navigate(ROUTES.FEEDS_NEW)
|
||||
}
|
||||
|
||||
function viewFeed(uuid: string) {
|
||||
history.push(ROUTES.FEEDS_PAGE.replace(':uuid', uuid))
|
||||
navigate(ROUTES.FEEDS_PAGE.replace(':uuid', uuid))
|
||||
}
|
||||
|
||||
function onDialogClose() {
|
||||
|
||||
Reference in New Issue
Block a user