Skip to content

Commit

Permalink
[docs] Fix warning mode pass to React.Fragment (#32729)
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp authored May 11, 2022
1 parent 2c4f912 commit 7028a34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions docs/src/modules/components/Demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ export default function Demo(props) {

const [showAd, setShowAd] = React.useState(false);

const isJoy = asPathWithoutLang.startsWith('/joy-ui');
const DemoRoot = asPathWithoutLang.startsWith('/joy-ui') ? DemoRootJoy : DemoRootMaterial;
const Wrapper = asPathWithoutLang.startsWith('/joy-ui') ? BrandingProvider : React.Fragment;

Expand All @@ -261,7 +262,7 @@ export default function Demo(props) {
onMouseEnter={handleDemoHover}
onMouseLeave={handleDemoHover}
>
<Wrapper mode={mode}>
<Wrapper {...(isJoy && { mode })}>
<InitialFocus
aria-label={t('initialFocusLabel')}
action={initialFocusRef}
Expand All @@ -279,7 +280,7 @@ export default function Demo(props) {
</DemoRoot>
<AnchorLink id={`${demoName}.js`} />
<AnchorLink id={`${demoName}.tsx`} />
<Wrapper mode={mode}>
<Wrapper {...(isJoy && { mode })}>
{demoOptions.hideToolbar ? null : (
<NoSsr defer fallback={<DemoToolbarFallback />}>
<React.Suspense fallback={<DemoToolbarFallback />}>
Expand Down
11 changes: 6 additions & 5 deletions docs/src/modules/components/MarkdownDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ function MarkdownDocs(props) {

const { description, location, rendered, title, toc, headers } = docs[userLanguage] || docs.en;

const Provider = asPathWithoutLang.startsWith('/joy-ui') ? CssVarsProvider : React.Fragment;
const Wrapper = asPathWithoutLang.startsWith('/joy-ui') ? BrandingProvider : React.Fragment;
const isJoy = asPathWithoutLang.startsWith('/joy-ui');
const Provider = isJoy ? CssVarsProvider : React.Fragment;
const Wrapper = isJoy ? BrandingProvider : React.Fragment;

return (
<AppLayoutDocs
Expand All @@ -54,11 +55,11 @@ function MarkdownDocs(props) {
toc={toc}
>
<Provider>
{asPathWithoutLang.startsWith('/joy-ui') && <JoyModeObserver mode={theme.palette.mode} />}
{isJoy && <JoyModeObserver mode={theme.palette.mode} />}
{rendered.map((renderedMarkdownOrDemo, index) => {
if (typeof renderedMarkdownOrDemo === 'string') {
return (
<Wrapper key={index} mode={theme.palette.mode}>
<Wrapper key={index} {...(isJoy && { mode: theme.palette.mode })}>
<MarkdownElement renderedMarkdown={renderedMarkdownOrDemo} />
</Wrapper>
);
Expand All @@ -67,7 +68,7 @@ function MarkdownDocs(props) {
if (renderedMarkdownOrDemo.component) {
const Component = markdownComponents[renderedMarkdownOrDemo.component];
return (
<Wrapper key={index} mode={theme.palette.mode}>
<Wrapper key={index} {...(isJoy && { mode: theme.palette.mode })}>
<Component headers={headers} options={renderedMarkdownOrDemo} />
</Wrapper>
);
Expand Down

0 comments on commit 7028a34

Please sign in to comment.