Hi guys, I am a beginner programmer just started working on a router.
I have two questions. What is the difference between using <Link to="/page"> and <a href="page"> ? Both make the same request to get /page , but I get an error when I use <a href="page"> , but it works when I use <Link to="/page"> when I find routes. I donβt understand how there could be any difference when I know that both renderings have an exact url
The second is the weird arrow function in the documentation for interacting with the v4 router
const About = () => ( <div> <h2>About</h2> </div> )
I know () => {} they are new in ES6, but I can not find anything in ordinary brackets instead of parentheses. What they?
Edit
My class is index.js (I have all the imports)
render(( <Router> <div> <Route component={App}/> </div> </Router> ), document.getElementById('root') );
My class is App.js
class App extends Component { render() { return ( <div className="container"> <header> <span className="icn-logo"><i className="material-icons">code</i></span> <ul className="main-nav"> <li><Link to="/">Home</Link></li> <li><Link to="/about">About</Link></li> <li><Link to="/teachers">Teachers</Link></li> <li><Link to="/courses">Courses</Link></li> </ul> </header> <Route exact path="/" component={Home}/> <Route path="/about" component={About}/> <Route path="/teachers" component={Teachers}/> <Route path="/courses" component={Course}/> </div> ); } } export default App;
The error I am getting. Cannot GET /about in the browser when I try to switch to localhost:8080/about . However, when I click on the about button, it goes to the exact URL /about and displays fine
source share