Error for ReactJs.Net server with ES6
I am working with ReactJs.Net and MVC5 application and am facing server side break issues when using ES6 and babel transpiler. I have used the exponent loader to expose the component all over the world. But it only works in ES5 syntax. If I am using ES6 and Webpack for bundling I get the following error in @ Html.React () function.
Error while rendering "Hello" to "react_Hq6cd5QfaUu26XrhGgZA": Script throws exception: Minified React error # 130; visit http://facebook.github.io/react/docs/error-decoder.html ?
Code for ~ Jsx / Components / Helloworld.jsx
import React, {Component} from 'react';
export default class Helloworld extends Component {
render() {
return (
<div>Hello {this.props.name} ,This is my first react component.</div>
);
}
}
Code for ~Jsx/server.jsx
import Hello from 'expose?Hello!./components/Helloworld' ;
webpack.config.js
var path = require('path');
var webpack = require('webpack');
module.exports =
{
entry: ['./Jsx/server.jsx'],
output: { path: './build', filename: 'main.js' },
module: {
loaders: [
{
test: /\.jsx$/,
loader: ['babel-loader'],
include: path.resolve(__dirname, 'Jsx'),
query: {
presets: ['es2015', 'react']
}
},
]
},
resolve: {
extensions: ['', '.js', '.jsx']
}
//watch:true
}
RectConfig.cs
ReactSiteConfiguration.Configuration
.SetLoadBabel(false)
.AddScriptWithoutTransform("~/build/main.js");
The above code works fine if i use the below ES5 syntax for Helloworld component
var React=require('react');
var Helloworld = React.createClass({
render: function() {
return (
<div>
Hello {this.props.name} ,This is my first react component.
</div>
);
}
});
module.exports=Helloworld;
Please help me if anyone knows a solution.
+3
source to share
No one has answered this question yet
Check out similar questions: