I'm trying to apply a padding/margin on the Navbar so the links have some space between them.
I've tried renaming the const but it conflicts itself because I can't use a identifier twice in one file. Parsing error: Identifier 'Route' has already been declared.
import React, { Component } from 'react';
import { BrowserRouter, Route, Switch } from "react-router-dom";
import Home from "./components/Home";
import Projects from "./components/Projects";
import About from "./components/About";
import Contact from "./components/Contact";
import Error from "./components/Error";
import Navigation from "./components/Navigation";
class App extends Component {
render() {
return (
<BrowserRouter>
<Navigation />
<Switch>
<Route path="/" component={ Home } exact />
<Route path="/Projects" component={ Projects } />
<Route path="/About" component={ About } />
<Route path="/Contact" component={ Contact } />
<Route component={ Error } />
</Switch>
</BrowserRouter>
);
}
}
export default App;
import React from 'react';
import { NavLink } from "react-router-dom";
import { NavItem} from '../style/Navigation.style';
const Navigation = () => {
return (
<NavItem>
<NavLink to="/">Home</NavLink>
<NavLink to="/Projects">Projects</NavLink>
<NavLink to="/Contact">Contact</NavLink>
<NavLink to="/About">About</NavLink>
</NavItem>
);
};
export default Navigation;
import styled from 'styled-components';
import {NavLink} from "react-router-dom";
export const NavItem = styled(NavLink)`
Display: Flex;
flex-direction: row;
justify-content: center;
align-items: center;
text-align: center;
Margin: 10px;
padding: 10px;
`;
import React from "react";
const Home = () => {
return (
<div>
<p>Home</p>
</div>
);
};
export default Home;
[This is how it looks so far] https://i.stack.imgur.com/X4pKv.png