Answer the question
In order to leave comments, you need to log in
How to render React on the server?
The task is to get html on the server side from React components.
Stumbled with babel.
In general, in all examples, all templates are written without quotes. I am also getting an error. I understand that babel is needed.
Connected.
var code = 'export default React.createClass({
getInitialState() {
return { num: this.getRandomNumber() };
},
getRandomNumber(): number {
return Math.ceil(Math.random() * 6);
},
render(): any {
return <div>
Your dice roll:
{this.state.num}
</div>;
}
});';
var qwerty = babel.transform(code, {
presets: [
"es2015",
"react",
"stage-0"
]
});
console.info(qwerty);
Answer the question
In order to leave comments, you need to log in
I highly recommend improving your Google skills.
https://github.com/zeit/next.js/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question