I’m building my first expo/react app. I keep getting an “Unexpected token” error message in App.js:
export default class App extends React.Component {
const [message, setMessage] = useState("...");
the error being in the [
of the line beginning const
.
As best I can tell, this is a babel issue: this syntax was introduced in ES2015. AFAICS, this should be resolvable by adding @babel/preset-env to babel.config.js thus:
module.exports = function(api) {
api.cache(true);
return {
presets: [
'@babel/react',
'@babel/env',
],
plugins: [
'@babel/proposal-class-properties',
],
};
};
Bundling succeeds, but the error remains! What am I missing?