"Parsing error: Missing semicolon".
SyntaxError: client\src\App.js: Missing semicolon (15:21)
This error is showing on componentDidMount() line.
and the full code is given below.
import React, { Component } from "react";
import AppNavBar from "./components/AppNavbar";
import ShoppingList from "./components/ShoppingList";
import ItemModal from "./components/ItemModal";
import { Container } from "reactstrap";
import { Provider } from "react-redux";
import store from "./store";
import { loadUser } from "./actions/authActions";
import "bootstrap/dist/css/bootstrap.min.css";
import "./App.css";
function App() {
componentDidMount() {
store.dispatch(loadUser());
}
return (
<Provider store={store}>
<div className="App">
<AppNavBar />
<Container>
<ItemModal />
<ShoppingList />
</Container>
</div>
</Provider>
);
}
export default App;
Import useEffect:
import { useEffect } from "react";
... and replace:
componentDidMount() {
store.dispatch(loadUser());
}
with:
useEffect(() => {
store.dispatch(loadUser());
}, []);