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

MDXTag Error: "components is not defined" #463

Closed
colshacol opened this issue Nov 21, 2018 · 23 comments
Closed

MDXTag Error: "components is not defined" #463

colshacol opened this issue Nov 21, 2018 · 23 comments

Comments

@colshacol
Copy link

colshacol commented Nov 21, 2018

Bug Report

Describe the bug

When visiting my local docz instance, I am met with the error components is not defined upon navigating (clicking on a sidebar link) to a specific component's view.

I am not quite sure what causes the bug. It seems as though my mdx files are compile to be <MDXTag> components, which accepts a prop components, but the identifier provided doesn't seem to exist in the file. 🤷‍♂️

To Reproduce

Clone, cd packages/core, npm i, npm run docz:dev.
https://github.com/colshacol/g2-ops-component-library
branch: "v1"
Working directly from the packages/core directory.

Expected behavior

I expect docz to show me the mdx documentation I have written for the specific component.

Environment

macOS High Sierra 10.13.6
node v11.1.0 / v10.8.0
npm v6.2.0 / v6.4.1
// doczrc.js
import { css } from 'docz-plugin-css'

export default {
  src: './src/new_components',
  plugins: [
    css({
      preprocessor: 'postcss',
      cssmodules: false,
      loaderOpts: {
        plugins: [],
      },
    }),
  ],
}
"docz": "^0.12.12",
"docz-plugin-css": "^0.11.0",

(Same error with 0.12.12, 0.12.11, 0.12.10, and 0.12.9.)

Additional context/Screenshots

Screen recording:
https://www.youtube.com/watch?v=XlirTYEnGmg

screen shot 2018-11-20 at 7 44 38 pm
screen shot 2018-11-20 at 11 24 53 pm
screen shot 2018-11-20 at 11 29 59 pm
screen shot 2018-11-20 at 11 30 16 pm

@colshacol
Copy link
Author

Note: Before making this issue, I had cleared my yarn cache, npm cache, deleted and re-installed dependencies many times.

I just gave it a go with yarn, and it seems that it did better, but still fell down. Now the error is props is not defined. Sill in the same place, though.

screen shot 2018-11-21 at 12 57 46 am

@colshacol
Copy link
Author

HelloWorld seems to be working fine now, though... 🤔

@colshacol colshacol mentioned this issue Nov 21, 2018
@danielbayerlein
Copy link

danielbayerlein commented Nov 21, 2018

Same error with the latest version of docz (0.12.12)

props is not defined

Stack trace
in MDXContent (created by AsyncComponent)
in AsyncComponent (created by Component)
in Component (created by t)
in t (created by y)
in y (created by c)
in c (created by ForwardRef)
in Component (created by AsyncRoute)
in div (created by Styled(div))
in Styled(div) (created by Context.Consumer)
in div (created by Styled(div))
in Styled(div) (created by Context.Consumer)
in div (created by Styled(div))
in Styled(div) (created by St)
in St (created by Context.Consumer)
in ThemeConfig (created by Gt)
in Gt (created by AsyncRoute)
in AsyncRoute (created by t)
in t (created by Context.Consumer)
in t (created by Context.Consumer)
in MDXProvider (created by DocPreview)
in DocPreview (created by Context.Consumer)
in ThemeProvider (created by Context.Consumer)
in ThemeConfig (created by Component)
in Component (created by Component)
in ThemeProvider (at Layout.js:52)
in Layout (created by Component)
in ScrollToTopBase (created by t)
in t (created by withRouter(ScrollToTopBase))
in withRouter(ScrollToTopBase) (created by Component)
in t (created by t)
in t (created by Component)
in DataServer (created by Component)
in Provider (created by Component)
in ErrorBoundary (created by Component)
in Component (at root.jsx:8)
in Root (created by HotExportedRoot)
in AppContainer (created by HotExportedRoot)
in HotExportedRoot (at app/index.jsx:15)

@KingScooty
Copy link

I'm getting the same error whenever I use the <Playground /> component.

@danielbayerlein
Copy link

@pedronauck Looks like a critical bug in the current version.

@idrakimuhamad
Copy link

I'm not getting the same error as the OP, but definitely getting the @danielbayerlein getting. The usage of Playground will always throw an error props is not defined

@robertpenner
Copy link

Also getting props is not defined when I use <Playground>.
Looking at the line where the error is thrown:

<Playground __codesandbox={`undefined`} __position={1} __code={`<MyComponent />`} __scope={{props,MyComponent}}>

It seems props should be this.props, judging by its position in the MDXContent component.

@robertpenner
Copy link

robertpenner commented Nov 22, 2018

I think this was the diff responsible (2 days ago in mdx-js):

mdx-js/mdx@c9c2b32#diff-b327bc77915c976f12c6d2efb717f068R112

Looks like in the refactoring to a class component, in the render method this.props should have replaced props.
(FWIW that code is in a double-nested template literal; good luck linting that.)

robertpenner referenced this issue in mdx-js/mdx Nov 22, 2018
* Stabilize UserLayout

Fixes #307

Pulls the layout for an MDX file into a reference that will be stable
across renders. Previously, a layout defined in MDX content as an
inline arrow function:

```js
export default ({ children, ...props }) => <div {...props}>{children}</div>
```

would result in function defined inline in render, causing the
reference to be created each time resulting in a remounting.

This PR stablizes the reference by placing the layout outside of
render in a class property, resulting in no remount.
@zWingz
Copy link

zWingz commented Nov 22, 2018

same error with props is not defined

@danielbayerlein
Copy link

danielbayerlein commented Nov 22, 2018

OK, it's a issue in mdx-js, see mdx-js/mdx#324

@johno
Copy link

johno commented Nov 22, 2018

Apologies for this issue, for the time being I recommend pinning @mdx-js/mdx@0.16.0, we'll have it fixed in MDX core tomorrow.

@adbayb
Copy link
Contributor

adbayb commented Nov 22, 2018

It could be interesting to match packages version exactly to minimize this sort of issue in the future (currently inside docz/packages/docz-core/package.json, there are carret ranges), what do you think ?

@pedronauck
Copy link
Member

Sorry guys, just now I saw this issue, I'm working right now to fix it 🙏

@pedronauck
Copy link
Member

Fixed, will be released in the next version

@berbecki
Copy link

@pedronauck - When?

@danielbayerlein
Copy link

@berbecki Once the release is created.

@pedronauck
Copy link
Member

Today @berbecki :)

@jasdeepsingh
Copy link

Not sure if 0.16.4 contains the fix for this issue - But I just tried that latest version and it doesn't work. Same error. @pedronauck

@pedronauck
Copy link
Member

Fixed on v0.12.13

@pedronauck
Copy link
Member

If bug keeps showing up, try to run yarn dev --debug to invalidate cache or re-install yarn stuff

@andrevvalle
Copy link

@pedronauck thanks!

@one-aalam
Copy link

Today @berbecki :)

Thanks for v0.12.13 @pedronauck Works like a charm!

@enzoferey
Copy link

enzoferey commented Nov 27, 2018

yarn [your-command] --debug works for me. But we use npm at work, so I have tried re-installing things and it's not working (of course I cleaned up the cache). Any idea why could it be ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests