Skip to content

Commit

Permalink
Remove warnings in example
Browse files Browse the repository at this point in the history
  • Loading branch information
djhi committed May 12, 2021
1 parent c1f94cc commit a9e28b7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
13 changes: 12 additions & 1 deletion examples/no-code/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { Root } from 'ra-no-code';
import { defaultTheme } from 'react-admin';
import {
unstable_createMuiStrictModeTheme,
createMuiTheme,
} from '@material-ui/core/styles';

// FIXME MUI bug https://github.com/mui-org/material-ui/issues/13394
const theme =
process.env.NODE_ENV !== 'production'
? unstable_createMuiStrictModeTheme(defaultTheme)
: createMuiTheme(defaultTheme);

ReactDOM.render(
<React.StrictMode>
<Root />
<Root theme={theme} />
</React.StrictMode>,
document.getElementById('root')
);
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ import {
createMuiTheme,
makeStyles,
ThemeProvider,
unstable_createMuiStrictModeTheme,
} from '@material-ui/core/styles';
import { defaultTheme } from 'ra-ui-materialui';
import {
defaultTheme as RaDefaultTheme,
RaThemeOptions,
} from 'ra-ui-materialui';
import FolderIcon from '@material-ui/icons/Folder';
import { Application } from './types';
import { NewApplicationForm } from './NewApplicationForm';
Expand All @@ -24,8 +28,19 @@ import {
storeApplicationsInStorage,
} from './applicationStorage';

export const ApplicationsDashboard = ({ onApplicationSelected }) => (
<ThemeProvider theme={createMuiTheme(defaultTheme)}>
const defaultTheme =
process.env.NODE_ENV !== 'production'
? unstable_createMuiStrictModeTheme(RaDefaultTheme)
: createMuiTheme(RaDefaultTheme);

export const ApplicationsDashboard = ({
onApplicationSelected,
theme = defaultTheme,
}: {
onApplicationSelected: any;
theme: RaThemeOptions;
}) => (
<ThemeProvider theme={createMuiTheme(theme)}>
<Applications onApplicationSelected={onApplicationSelected} />
</ThemeProvider>
);
Expand Down
6 changes: 4 additions & 2 deletions packages/ra-no-code/src/Root.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { RaThemeOptions } from 'ra-ui-materialui';
import * as React from 'react';
import { useMemo, useState } from 'react';
import { Admin } from './Admin';
import { ApplicationContext } from './ApplicationContext';
import { ApplicationsDashboard } from './ApplicationsDashboard';

export const Root = () => {
export const Root = ({ theme }: { theme: RaThemeOptions }) => {
const [application, setApplication] = useState();

const handleExitApplication = () => {
Expand All @@ -26,14 +27,15 @@ export const Root = () => {
if (context.application) {
return (
<ApplicationContext.Provider value={context}>
<Admin />
<Admin theme={theme} />
</ApplicationContext.Provider>
);
}

return (
<ApplicationsDashboard
onApplicationSelected={handleApplicationSelected}
theme={theme}
/>
);
};

0 comments on commit a9e28b7

Please sign in to comment.