when I use eggjs server-side rendering (I just want to get the rendered HTML), it is always reported that parsing jsx code or import syntax parsing failed. Here is my code:
"use strict" ;
require( "babel-polyfill" );
require( "babel-register" )({
presets: [ "env" , "react" , "stage-0" ],
});
const Controller = require( "egg" ).Controller;
const React = require( "react" );
const ReactDOMServer = require( "react-dom/server" );
const App = require(" //components" );
class HomeController extends Controller {
async index() {
const html = ReactDOMServer.renderToString(<App />);
this.ctx.body = "hi, egg" ;
}
}
module.exports = HomeController;
what should I do in a production environment? Ask the Great God for an answer. How do you do it?