Error Blog
Hi Guys ,
This blog is about the error Inline Babel script: 'this' is not allowed before super()
Problem Statement
Unable to load a html page in react js .
Error Details
error Log
ERROR DETAILS
babel.min.js:4 Uncaught SyntaxError: Inline Babel script: 'this' is not allowed before super()
3 | constructor() {
4 |
> 5 | this.state = {
| ^
6 | users: []
7 | }
8 | }
at r.buildCodeFrameError (babel.min.js:4)
at e.buildCodeFrameError (babel.min.js:23)
at e.ThisExpression (babel.min.js:7)
at e.o [as _call] (babel.min.js:22)
at e.a [as call] (babel.min.js:22)
at e.l [as visit] (babel.min.js:22)
at e.visitQueue (babel.min.js:22)
at e.visitSingle (babel.min.js:22)
at e.visit (babel.min.js:22)
at Function.v.node (babel.min.js:22)
Solution
As the error suggested , we modified the code and added super before using this .
Code Changes
List of files changed
constructor() {
super();
this.state = {
users: []
}
}
OUTPUT
Thanks for reading . Let me know your thoughts in the comments below .
No comments:
Post a Comment