From 53811b232428c5b27bad22f222ffce9c787fbb8b Mon Sep 17 00:00:00 2001 From: James Date: Sun, 22 Nov 2020 13:41:44 -0500 Subject: [PATCH] re-implements custom view in CustomComponents, types a few files --- demo/collections/CustomComponents/index.js | 4 +--- src/admin/components/Routes.tsx | 8 +++++--- src/express/admin.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/demo/collections/CustomComponents/index.js b/demo/collections/CustomComponents/index.js index e73c25352f1..d9401b2a05d 100644 --- a/demo/collections/CustomComponents/index.js +++ b/demo/collections/CustomComponents/index.js @@ -101,9 +101,7 @@ module.exports = { admin: { useAsTitle: 'title', components: { - views: { - List: ListView, - }, + List: ListView, }, }, }; diff --git a/src/admin/components/Routes.tsx b/src/admin/components/Routes.tsx index f059586c9dc..cb1da885115 100644 --- a/src/admin/components/Routes.tsx +++ b/src/admin/components/Routes.tsx @@ -1,6 +1,6 @@ import React, { Suspense, lazy, useState, useEffect } from 'react'; import { - Route, Switch, withRouter, Redirect, useHistory, + Route, Switch, withRouter, Redirect, useHistory, useLocation, } from 'react-router-dom'; import { useConfig } from './providers/Config'; import List from './views/collections/List'; @@ -23,6 +23,7 @@ const Unauthorized = lazy(() => import('./views/Unauthorized')); const Account = lazy(() => import('./views/Account')); const Routes = () => { + const { pathname } = useLocation(); const history = useHistory(); const [initialized, setInitialized] = useState(null); const { user, permissions, permissions: { canAccessAdmin } } = useAuth(); @@ -40,8 +41,9 @@ const Routes = () => { }, [routes, userSlug]); useEffect(() => { - history.replace(); - }, [history]); + // Clear location state on path change + history.replace(pathname, {}); + }, [history, pathname]); return ( }> diff --git a/src/express/admin.ts b/src/express/admin.ts index cb69f6679aa..d927a5beb33 100644 --- a/src/express/admin.ts +++ b/src/express/admin.ts @@ -6,7 +6,7 @@ import initWebpack from '../webpack/init'; const router = express.Router(); -function initAdmin() { +function initAdmin(): void { if (!this.config.admin.disable && process.env.NODE_ENV !== 'test') { this.initWebpack = initWebpack.bind(this);