When I try to test using expo start --web, I get this error in the browser -
Support for the experimental syntax 'classProperties' isn't currently enabled (30:28):
.
.
.
Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel config to enable transformation.
Even after I add the plugin using npm install --save-dev @babel/plugin-proposal-class-properties, the same error comes up. None of the solutions I found online work. Does anyone here know how I can fix this?
Are you intentionally using class properties? If not, maybe replace them. Otherwise check your babel.config.js to make sure it has a plugins section that references @babel/plugin-proposal-class-properties. I have not tried this myself, so not sure if it will work, but it seems to be what the error message is suggesting.
Could you post the code where you’re using the custom properties?
To answer your question, I was referring to the babel.config.js at the root of your project. If I create a new project with expo init I get a babel.config.js file at the root of the project. It looks as follows:
class SplashScreen extends React.Component {
static navigationOptions = { // this line is where the error points
title: 'Splash',
header: null,
gesturesEnabled: false
};
And thanks for letting me know but I do not have a babel.config.js file in my root directory. How is that possible?
I’m not sure. It could be because you’re on SDK 34.
Regarding your code, I have very similar code in one app and it works on the web with no complaints about class properties. The difference is that I’m on SDK 35.
I suspect the following from my package.json might be the reason it’s working in SDK 35:
in addition to the babel.config.js mentioned previously.
The only problem I have with running that app on the web is that it complains it can’t find assets/blah.png when in fact there are assets/blah@1x.png, assets/blah@2x.png and assets/blah@3x.png. So just for the purposes of testing your issue I copied all the *@3x.png files to *.png and it worked fine after that.