styleguidist/react-styleguidist

Error when importing component in Markdown file

Open

#1,345 opened on Apr 26, 2019

View on GitHub
 (4 comments) (0 reactions) (0 assignees)TypeScript (1,416 forks)github user discovery
bughelp wanted

Repository metrics

Stars
 (11,091 stars)
PR merge metrics
 (PR metrics pending)

Description

Current behavior

Hello, I am attempting to import a JSX component into a Markdown documentation file. I'm creating an alias for these styleguide-only view components in my styleguide.config.js:

module.exports = {
  ...  
  webpackConfig: {
    resolve: {
      alias: {
        styleguideComponents: path.resolve(STYLEGUIDE_PATH, './components')
      }
    }
  }
}

console.log'ing the path shows it to be as expected, and when I import a component in my Markdown file, it throws no errors:

```jsx noeditor
import { Do } from 'styleguideComponents';

<Do>
  You should do this thing.
</Do>

Here is the <Do /> component, for reference:

import React from 'react'

const Do = ({ children }) => (
  <div className='Do'>
    { children }
  </div>
)

export default Do

However, when I load the styleguide, I get a red error saying "SyntaxError: Missing initializer in const declaration". I am using the latest react-styleguidist version.

Any advice is much appreciated :)

Contributor guide