Reputation: 12184
I'm getting this error:
ERROR in ./src/Client/privacy-policy.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: /home/sashan/code/titan/src/Client/privacy-policy.js: Unexpected token (7:17)
5 | const PrivacyPolicy = createReactClass({
6 | render() {
> 7 | return ( <div dangerouslySetInnerHTML={ {__html: htmlContent} } />);
| ^
8 | }
9 | });
10 | export default PrivacyPolicy;
This is my babel config:
babel: {
presets: [
["@babel/preset-env", {
"targets": "> 0.25%, not dead",
"modules": false,
// This adds polyfills when needed. Requires core-js dependency.
// See https://babeljs.io/docs/en/babel-preset-env#usebuiltins
"useBuiltIns": "usage",
}]
],
}
This is how bable config is used:
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: CONFIG.babel
},
},
How can I resolve the compiler error? I just want to load some static html content.
Upvotes: 0
Views: 60
Reputation: 5038
Your Div needs a closing tag, it is not an element that can be written <div\>
rather make sure to write <div ....></div>
Upvotes: 0
Reputation: 4116
You need to include @babel/preset-react in your babel config for it to compile JSX
Try this
npm install --save-dev @babel/preset-react
{
"presets": ["@babel/preset-react"]
}
Upvotes: 2