Skip to content

Vue components created with JSX is not working in Markdown files #318

Closed
@HandOfGod94

Description

@HandOfGod94

vuepress-error.zip

  • OS: Windows 10
  • Node.js: v9.3.0
  • VuePress: 0.8.4
  • Browser: Google Chrome Version 66.0.3359.117 (Official Build) (64-bit)
  • Local installation
  • Package Manager used: yarn

I'm using VuePress for documenting my components. For demo, purpose I'm registering it globally in enhanceApp.js and using it .md files.

Attaching a reproducible project with a custom component.
I have used yarn to install dependecies.
To reproduce:

  1. Go to src/components/MyComponent.js.
  2. Toggle the return statement to see the output.

To view docs: run yarn docs:dev

I guess the problem is that it VuePress doesn't have babel-plugin-transform-vue-jsx. So is this thing in roadmap, or will not be supported? Is there any other way to handle JSX in render function for VuePress

If I use createElement method directly with arguments, its rendering properly.

export default {
  name: 'my-component',
    render (h) {
        return h('div', {}, this.$slots.default)
    }
}

Now in my .md files if I use

<se-container>Hello World</se-container>

Its working correctly.
But if I use JSX in render method, then it's showing ReferenceError: React is not defined in console.

export default {
    name: 'my-component',
    render (h) {
        return (
            <div>{this.$slots.default}</div>
        )
    }
}

error

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: enhancementRequest to enhance an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions