Skip to content

Commit

Permalink
Fix error in CoreAdminUI in development mode
Browse files Browse the repository at this point in the history
closes #4322
  • Loading branch information
fzaninotto committed Feb 19, 2020
1 parent 151bb8c commit ec6082b
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 21 deletions.
3 changes: 3 additions & 0 deletions examples/simple/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ module.exports = {
'OptionTextElement',
'RedirectionSideEffect',
'RefreshSideEffect',
'AdminUIProps',
'AdminContextProps',
'AdminRouterProps',
]),
].concat(
process.env.NODE_ENV === 'development'
Expand Down
7 changes: 5 additions & 2 deletions packages/ra-core/src/core/CoreAdminUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const DefaultLayout: FunctionComponent<LayoutProps> = ({ children }) => (
<>{children}</>
);

export interface CoreAdminUIProps {
export interface AdminUIProps {
catchAll?: CatchAllComponent;
children?: AdminChildren;
customRoutes?: CustomRoutes;
Expand All @@ -33,7 +33,10 @@ export interface CoreAdminUIProps {
title?: TitleComponent;
}

const CoreAdminUI: FunctionComponent<CoreAdminUIProps> = ({
// for BC
export type CoreAdminUIProps = AdminUIProps;

const CoreAdminUI: FunctionComponent<AdminUIProps> = ({
catchAll = Noop,
children,
customRoutes = [],
Expand Down
9 changes: 6 additions & 3 deletions packages/ra-core/src/core/components.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import CoreAdmin from './CoreAdmin';
import CoreAdminContext from './CoreAdminContext';
import CoreAdminRouter from './CoreAdminRouter';
import CoreAdminUI from './CoreAdminUI';
import CoreAdminContext, { AdminContextProps } from './CoreAdminContext';
import CoreAdminRouter, { AdminRouterProps } from './CoreAdminRouter';
import CoreAdminUI, { AdminUIProps } from './CoreAdminUI';
import createAdminStore from './createAdminStore';
import RoutesWithLayout from './RoutesWithLayout';
import Resource from './Resource';

export {
CoreAdmin,
CoreAdminContext,
AdminContextProps,
CoreAdminRouter,
AdminRouterProps,
CoreAdminUI,
AdminUIProps,
createAdminStore,
RoutesWithLayout,
Resource,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { CoreAdminContext } from 'ra-core';
import React, { FC } from 'react';
import { CoreAdminContext, AdminContextProps } from 'ra-core';

import defaultI18nProvider from './defaultI18nProvider';

const AdminContext = CoreAdminContext;
const AdminContext: FC<AdminContextProps> = props => (
<CoreAdminContext {...props} />
);

AdminContext.defaultProps = {
i18nProvider: defaultI18nProvider,
Expand Down
10 changes: 0 additions & 10 deletions packages/react-admin/src/AdminRouter.ts

This file was deleted.

13 changes: 13 additions & 0 deletions packages/react-admin/src/AdminRouter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { FC } from 'react';
import { CoreAdminRouter, AdminRouterProps } from 'ra-core';
import { Loading } from 'ra-ui-materialui';

const AdminRouter: FC<AdminRouterProps> = props => (
<CoreAdminRouter {...props} />
);

AdminRouter.defaultProps = {
loading: Loading,
};

export default AdminRouter;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CoreAdminUI } from 'ra-core';
import React, { FC } from 'react';
import { CoreAdminUI, AdminUIProps } from 'ra-core';
import {
Layout as DefaultLayout,
Loading,
Expand All @@ -7,7 +8,7 @@ import {
NotFound,
} from 'ra-ui-materialui';

const AdminUI = CoreAdminUI;
const AdminUI: FC<AdminUIProps> = props => <CoreAdminUI {...props} />;

AdminUI.defaultProps = {
layout: DefaultLayout,
Expand All @@ -17,6 +18,4 @@ AdminUI.defaultProps = {
logout: Logout,
};

AdminUI.displayName = 'AdminUI';

export default AdminUI;

0 comments on commit ec6082b

Please sign in to comment.