Skip to content

Commit

Permalink
Merge pull request #4242 from CarsonF/bugfix/ssr
Browse files Browse the repository at this point in the history
Small fixes for SSR
  • Loading branch information
fzaninotto authored Jan 8, 2020
2 parents 1210e50 + cad005b commit c633422
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
10 changes: 7 additions & 3 deletions packages/ra-core/src/core/CoreAdminContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@ React-admin requires a valid dataProvider function to work.`);
<AuthContext.Provider value={finalAuthProvider}>
<DataProviderContext.Provider value={finalDataProvider}>
<TranslationProvider i18nProvider={i18nProvider}>
<ConnectedRouter history={finalHistory}>
{children}
</ConnectedRouter>
{typeof window !== 'undefined' ? (
<ConnectedRouter history={finalHistory}>
{children}
</ConnectedRouter>
) : (
children
)}
</TranslationProvider>
</DataProviderContext.Provider>
</AuthContext.Provider>
Expand Down
2 changes: 0 additions & 2 deletions packages/ra-core/src/i18n/TranslationProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, {
useCallback,
useMemo,
Children,
ReactElement,
FunctionComponent,
} from 'react';

Expand All @@ -13,7 +12,6 @@ import { I18nProvider } from '../types';
interface Props {
locale?: string;
i18nProvider: I18nProvider;
children: ReactElement<any>;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion packages/ra-ui-materialui/src/layout/Title.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { useTranslate, warning } from 'ra-core';

const Title = ({ className, defaultTitle, locale, record, title, ...rest }) => {
const translate = useTranslate();
const container = document.getElementById('react-admin-title');
const container =
typeof document !== 'undefined'
? document.getElementById('react-admin-title')
: null;
if (!container) return null;
warning(!defaultTitle && !title, 'Missing title prop in <Title> element');

Expand Down

0 comments on commit c633422

Please sign in to comment.