i defined isAuth in Line 14 but i got error “srcApp.js
Line 25:13: ‘isAuth’ is not defined no-undef”
idk, maybe i defined it wrong, looking up for your help, thanks
import React, { Component } from 'react';
import './css/main.css';
import { BrowserRouter as Router, Routes, Route, Link } from 'react-router-dom';
import Home from './pages/Home';
import CreatePost from './pages/CreatePost';
import Login from './pages/Login';
class App extends Component {
constructor(props) {
super(props);
this.state = {
isAuth: false,
setIsAuth: false
};
}
render() {
return (
<Router>
<nav>
<Link to="/">Home</Link>
<Link to="/createpost"> Create New Post</Link>
{!isAuth && <Link to="/login">Login</Link>}
</nav>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/login" element={<Login setIsAuth={this.state.setIsAuth} />} />
<Route path="/createpost" element={<CreatePost />} />
</Routes>
</Router>
);
}
}
export default App;