Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My screen getting blank when i use mdx live editor. #5555

Closed
5 tasks done
fiqryq opened this issue Sep 11, 2021 · 12 comments
Closed
5 tasks done

My screen getting blank when i use mdx live editor. #5555

fiqryq opened this issue Sep 11, 2021 · 12 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@fiqryq
Copy link

fiqryq commented Sep 11, 2021

🐛 Bug Report

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io
  • I have read the console error message carefully (if applicable)

Description

I try to use MDX using livecodeblock , everything is okay until I try to delete all code on the live editor and when i press delete one more time my screen getting blank and my console give me this code : Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.

Have you read the Contributing Guidelines on issues?

Yes

Expected behavior

i can delete my code on the live editor.

Actual behavior

console code : Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.

Screen Shot 2021-09-11 at 22 48 27

Your environment

Reproducible demo

Use https://new.docusaurus.io to create a CodeSandbox reproducible demo of the bug.

(Paste the link to an example repo, including a docusaurus.config.js, and exact instructions to reproduce the issue.)

@fiqryq fiqryq added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Sep 11, 2021
@lex111
Copy link
Contributor

lex111 commented Sep 11, 2021

Could you please provide reproducible code or video? For example, I don't see an error if I delete code from the section on docs website.

image

@ChristopherHButler
Copy link

I'm having the same or similar issue. I tried following the instructions at https://docusaurus.io/docs/markdown-features/code-blocks#interactive-code-editor to add a live code editor and when I add the live tag to the meta string my app basically crashes. I have also attached a screenshot with console output. As soon as I remove the live tag everything works fine again.

Screenshot 2021-09-11 at 20 50 53

docusaurus.config.js:

const lightCodeTheme = require('prism-react-renderer/themes/github');
const darkCodeTheme = require('prism-react-renderer/themes/dracula');


// With JSDoc @type annotations, IDEs can provide config autocompletion
/** @type {import('@docusaurus/types').DocusaurusConfig} */
(module.exports = {
  title: 'Deez Docs',
  tagline: 'Take a look at deez docs',
  url: 'https://deez-docs.vercel.app/',
  baseUrl: '/',
  onBrokenLinks: 'warn',
  onBrokenMarkdownLinks: 'warn',
  favicon: 'img/favicon.ico',
  organizationName: 'ChristopherHButler',
  projectName: 'docs',

  presets: [
    [
      '@docusaurus/preset-classic',
      /** @type {import('@docusaurus/preset-classic').Options} */
      ({
        docs: {
          routeBasePath: 'docs',
          path: 'docs',
          sidebarPath: require.resolve('./sidebars.js'),
          lastVersion: 'current',
          onlyIncludeVersions: ['current'],
          editUrl: 'https://github.com/ChristopherHButler/docs',
        },
        // blog: {
        //   showReadingTime: true,
        //   // Please change this to your repo.
        //   editUrl:
        //     'https://github.com/ChristopherHButler/docs/blog/',
        // },
        theme: {
          customCss: require.resolve('./src/css/custom.css'),
        },
      }),
    ],
  ],

  plugins: [
    [
      '@docusaurus/plugin-content-docs',
      {
        id: 'development',
        path: 'docz/engineering/development',
        routeBasePath: 'docz/engineering/development',
        sidebarPath: require.resolve('./sidebars.js'),
      }, 
    ],
    [
      '@docusaurus/plugin-content-docs',
      {
        id: 'design',
        path: 'docz/engineering/design',
        routeBasePath: 'docz/engineering/design',
        sidebarPath: require.resolve('./sidebars.js'),
      }, 
    ],
    [
      '@docusaurus/plugin-content-docs',
      {
        id: 'architecture',
        path: 'docz/engineering/architecture',
        routeBasePath: 'docz/engineering/architecture',
        sidebarPath: require.resolve('./sidebars.js'),
      }, 
    ],
    [
      '@docusaurus/plugin-content-docs',
      {
        id: 'javascript',
        path: 'docz/engineering/javascript',
        routeBasePath: 'docz/engineering/javascript',
        sidebarPath: require.resolve('./sidebars.js'),
      }, 
    ],
    [
      '@docusaurus/plugin-content-docs',
      {
        id: 'typescript',
        path: 'docz/engineering/typescript',
        routeBasePath: 'docz/engineering/typescript',
        sidebarPath: require.resolve('./sidebars.js'),
      }, 
    ],
    [
      '@docusaurus/plugin-content-docs',
      {
        id: 'react',
        path: 'docz/engineering/react',
        routeBasePath: 'docz/engineering/react',
        sidebarPath: require.resolve('./sidebars.js'),
      }, 
    ],
    [
      '@docusaurus/plugin-content-docs',
      {
        id: 'react-typescript',
        path: 'docz/engineering/react-typescript',
        routeBasePath: 'docz/engineering/react-typescript',
        sidebarPath: require.resolve('./sidebars.js'),
      }, 
    ],
    [
      '@docusaurus/plugin-content-docs',
      {
        id: 'reactnative',
        path: 'docz/engineering/react-native',
        routeBasePath: 'docz/engineering/react-native',
        sidebarPath: require.resolve('./sidebars.js'),
      }, 
    ],
    [
      '@docusaurus/plugin-content-docs',
      {
        id: 'preact',
        path: 'docz/engineering/preact',
        routeBasePath: 'docz/engineering/preact',
        sidebarPath: require.resolve('./sidebars.js'),
      }, 
    ],
  ],

  themes: ['@docusaurus/theme-live-codeblock'],

  themeConfig:
    /** @type {import('@docusaurus/preset-classic').ThemeConfig} */
    ({
      navbar: {
        title: 'Docs',
        logo: {
          alt: 'Docs Logo',
          src: 'img/logo.svg',
        },
        items: [
          {
            label: 'Dev',
            type: 'dropdown',
            position: 'left',
            items: [
              {
                label: 'JavaScript',
                to: '/docz/engineering/javascript/index',
                activeBaseRegex: `/javascript/`,
              },
              {
                label: 'TypeScript',
                to: 'docz/engineering/typescript/index',
                activeBaseRegex: `/typescript/`,
              },
              {
                label: 'React',
                to: 'docz/engineering/react/intro',
                activeBaseRegex: `/react/`,
              },
              {
                label: 'React + TypeScript',
                to: 'docz/engineering/react-typescript/index',
                activeBaseRegex: `/ts-react/`,
              },
              {
                label: 'React Native',
                to: 'docz/engineering/react-native/index',
                activeBaseRegex: `/react-native/`,
              },
              {
                label: 'Preact',
                to: 'docz/engineering/preact/index',
                activeBaseRegex: `/preact/`,
              },
            ],
          },
          {
            label: 'Management',
            type: 'dropdown',
            docId: 'intro',
            position: 'left',
            items: [
              {
                label: 'Coming Soon',
                type: 'doc',
                docId: 'intro',
              }
              // {
              //   label: 'Leadership',
              //   to: '/management/leadership/intro',
              //   activeBaseRegex: `/management/leadership/`,
              // },
              // {
              //   label: 'Strategy',
              //   type: 'doc',
              //   docId: 'intro',
              // },
              // {
              //   label: 'Marketing',
              //   type: 'doc',
              //   docId: 'intro',
              // },
            ],
          },
          {
            label: 'UX Design',
            type: 'dropdown',
            position: 'left',
            items: [
              {
                label: 'Coming Soon',
                type: 'doc',
                docId: 'intro',
              }
              // {
              //   label: 'Information Architecture',
              //   type: 'doc',
              //   docId: 'intro',
              // },
              // {
              //   label: 'Interaction Design',
              //   type: 'doc',
              //   docId: 'intro',
              // },
              // {
              //   label: 'User Research',
              //   type: 'doc',
              //   docId: 'intro',
              // },
            ],
          },
          // {to: '/blog', label: 'Blog', position: 'left'},
          {
            href: 'https://github.com/ChristopherHButler/docs',
            position: 'right',
            className: 'header-github-link',
            'aria-label': 'GitHub repository',
          },
        ],
      },
      footer: {
        style: 'dark',
        links: [
          {
            title: 'Docs',
            items: [
              {
                label: 'Software Engineering',
                to: '/docs/engr',
              },
              {
                label: 'Engineering Management',
                to: '/docs/management',
              },
              {
                label: 'UX Design',
                to: '/docs/design',
              },
            ],
          },
          {
            title: 'Social',
            items: [
              {
                label: 'LinkedIn',
                href: 'https://www.linkedin.com/in/christopherharoldbutler/',
              },
              {
                label: 'GitHub',
                href: 'https://github.com/ChristopherHButler',
              },
            ],
          },
          // {
          //   title: 'More',
          //   items: [
          //     {
          //       label: 'Blog',
          //       to: '/blog',
          //     },
          //     {
          //       label: 'GitHub',
          //       href: 'https://github.com/facebook/docusaurus',
          //     },
          //   ],
          // },
        ],
        copyright: `Copyright © ${new Date().getFullYear()} Deez Docs.`,
      },
      prism: {
        theme: lightCodeTheme,
        darkTheme: darkCodeTheme,
      },
    }),
});

my package.json:

{
  "name": "docs",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "docusaurus": "docusaurus",
    "start": "docusaurus start",
    "build": "docusaurus build",
    "swizzle": "docusaurus swizzle",
    "deploy": "docusaurus deploy",
    "clear": "docusaurus clear",
    "serve": "docusaurus serve",
    "write-translations": "docusaurus write-translations",
    "write-heading-ids": "docusaurus write-heading-ids"
  },
  "dependencies": {
    "@docusaurus/core": "2.0.0-beta.6",
    "@docusaurus/plugin-content-docs": "^2.0.0-beta.6",
    "@docusaurus/preset-classic": "2.0.0-beta.6",
    "@docusaurus/theme-live-codeblock": "^2.0.0-beta.6",
    "@mdx-js/react": "^1.6.21",
    "@svgr/webpack": "^5.5.0",
    "clsx": "^1.1.1",
    "file-loader": "^6.2.0",
    "prism-react-renderer": "^1.2.1",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "styled-components": "^5.3.1",
    "url-loader": "^4.1.1"
  },
  "browserslist": {
    "production": [
      ">0.5%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}


@lex111
Copy link
Contributor

lex111 commented Sep 11, 2021

@ChristopherHButler I need reproducible repo, could you provide it?

@ChristopherHButler
Copy link

@lex111 sure thing. Here is my repo: https://github.com/ChristopherHButler/docs.

I do not have my docs in the docs folder. You can find the example of the broken live codeblock under docz > engineering > typescript > 1-basics > 00-introduction.md. I just copied in the example from the docusaurus site at line 11.

Let me know if you need anything else

@lex111
Copy link
Contributor

lex111 commented Sep 11, 2021

@ChristopherHButler thanks, but in your case, the problem with React version mismatch (you use v17, but the latest minor version react-live 2.3.0 rewritten on hooks uses v16). yarn can resolve this automatically, but npm you use doesn't.

A workaround would be to downgrade React to v16/run app via yarn instead of npm/add webpack alias. But it would be better if we just use the previous version react-live 2.2.0. I created PR for this #5556.

@ChristopherHButler
Copy link

Thanks @lex111 I'll downgrade for now and maybe keep an eye out for that PR.

@fiqryq
Copy link
Author

fiqryq commented Sep 12, 2021

@lex111 this my video ,
https://www.youtube.com/watch?v=wMnr6ZMOCr4

docusaurus.config.js

const lightCodeTheme = require("prism-react-renderer/themes/github");
const darkCodeTheme = require("prism-react-renderer/themes/dracula");

/** @type {import('@docusaurus/types').DocusaurusConfig} */
module.exports = {
  title: "fiqryq",
  tagline: "Membanteng",
  url: "https://fiqryq.github.io",
  baseUrl: "/",
  onBrokenLinks: "throw",
  onBrokenMarkdownLinks: "warn",
  favicon: "/img/favicon.ico",
  organizationName: "fiqryq",
  projectName: "porfolio",
  themes: ["@docusaurus/theme-live-codeblock"],
  themeConfig: {
    navbar: {
      title: "Hi there 👋",
      logo: {
        alt: "My Site Logo",
        src: "img/icon.svg",
      },
      items: [
        { to: "/", label: "Blog", position: "left" },
        {
          type: "doc",
          docId: "index",
          position: "left",
          label: "About me",
        },
        {
          href: "https://github.com/fiqryq",
          label: "GitHub",
          position: "right",
        },
      ],
    },
    footer: {
      style: "dark",
      links: [
        {
          title: "Support me",
          items: [
            {
              label: "Saweria",
              href: "https://saweria.co/fiqryq",
            },
          ],
        },
        {
          title: "Social Media",
          items: [
            {
              label: "Twitter",
              href: "https://twitter.com/fiqryq",
            },
            {
              label: "Instagam",
              href: "https://instagram.com/fiqryq",
            },
          ],
        },
      ],
      copyright: `Copyright © ${new Date().getFullYear()} Fiqry choerudin.`,
    },
    prism: {
      theme: lightCodeTheme,
      darkTheme: darkCodeTheme,
    },
  },
  presets: [
    [
      "@docusaurus/preset-classic",
      {
        docs: {
          sidebarPath: require.resolve("./sidebars.js"),
          // Please change this to your repo.
          // editUrl:
          //   "https://github.com/facebook/docusaurus/edit/master/website/",
        },
        blog: {
          showReadingTime: true,
          routeBasePath: "/",
          // Please change this to your repo.
          // editUrl:
          //   "https://github.com/facebook/docusaurus/edit/master/website/blog/",
        },
        theme: {
          customCss: require.resolve("./src/css/custom.css"),
        },
      },
    ],
  ],
};

package.json

{
  "name": "portfolio",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "docusaurus": "docusaurus",
    "start": "docusaurus start",
    "build": "docusaurus build",
    "swizzle": "docusaurus swizzle",
    "deploy": "docusaurus deploy",
    "clear": "docusaurus clear",
    "serve": "docusaurus serve",
    "write-translations": "docusaurus write-translations",
    "write-heading-ids": "docusaurus write-heading-ids"
  },
  "dependencies": {
    "@docusaurus/core": "^2.0.0-beta.6",
    "@docusaurus/preset-classic": "^2.0.0-beta.6",
    "@docusaurus/theme-live-codeblock": "^2.0.0-beta.6",
    "@mdx-js/react": "^1.6.21",
    "@svgr/webpack": "^5.5.0",
    "clsx": "^1.1.1",
    "file-loader": "^6.2.0",
    "prism-react-renderer": "^1.2.1",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "url-loader": "^4.1.1"
  },
  "browserslist": {
    "production": [
      ">0.5%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

@lex111
Copy link
Contributor

lex111 commented Sep 12, 2021

@fiqryq your video is not available, could you provide reproducible repo with broken live code block?

image

@fiqryq
Copy link
Author

fiqryq commented Sep 12, 2021

@fiqryq your video is not available, could you provide reproducible repo with broken live code block?

image

sorry my bad i set private video on my youtube , here my video :

Screen.Recording.2021-09-12.at.09.20.22.mp4

@Josh-Cena
Copy link
Collaborator

I was discussing with someone on Discord about this as well, it's specific to the case where an invalid React child (e.g. an object like console) is passed to the live scope without being wrapped by a function. Seems this is caused by a bad error boundary

@lex111
Copy link
Contributor

lex111 commented Sep 12, 2021

The bug is reproduced on react-live playground https://react-live.netlify.app/, so the issue related with this dependency.

@slorber
Copy link
Collaborator

slorber commented Sep 22, 2021

Hey

Merged #5556 so please test and let us know if canary doesn't fix the problems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

No branches or pull requests

5 participants