Skip to content

Top level element should be a tag or function which returns a tag #3

@inspiraller

Description

@inspiraller

Hi
I have installed this plugin but having problems.

$ npm install jsx-to-html

myreactfile.jsx

import React, { Component } from 'react';
import { render } from 'jsx-to-html';

class App extends Component {
	getComp(){
	  	var content = render(<div className="hello">hello</div>);
		console.log('content = ', content);
		return ('<div>hello</div>');
	}
	render() {
    	return (
    		<div className="all">
			{this.getComp()}
		</div>
		)
	}
}

ReactDOM.render(
	<App/>,
	document.getElementById('app')
);

I am getting error:
Uncaught Error: Top level element should be a tag or function which returns a tag

I have tried adding the plugin via .babelrc but that gives me an error too so I'm not entirely sure the plugin has loaded:

.babelrc

{
  "presets" : ["es2015", "react"],
	"plugins": [
 		["jsx-to-html/babel-plugin",
 		{ 
 			"blacklist": ["react"]
 		}]
	]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions