Skip to content

Commit

Permalink
re-implements custom view in CustomComponents, types a few files
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikrut committed Nov 22, 2020
1 parent 3344656 commit 53811b2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 1 addition & 3 deletions demo/collections/CustomComponents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ module.exports = {
admin: {
useAsTitle: 'title',
components: {
views: {
List: ListView,
},
List: ListView,
},
},
};
8 changes: 5 additions & 3 deletions src/admin/components/Routes.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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();
Expand All @@ -40,8 +41,9 @@ const Routes = () => {
}, [routes, userSlug]);

useEffect(() => {
history.replace();
}, [history]);
// Clear location state on path change
history.replace(pathname, {});
}, [history, pathname]);

return (
<Suspense fallback={<Loading />}>
Expand Down
2 changes: 1 addition & 1 deletion src/express/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 53811b2

Please sign in to comment.