0

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

5555
  • 1
  • 2
  • Duplicate: https://stackoverflow.com/questions/53332428/styled-components-is-saying-wrapped-styled-around-your-react-component-compon/53333912#53333912 – Matt Carlotta Apr 23 '19 at 22:20

1 Answers1

0

The main issue is you're trying to style the Navlink and then trying to display Navlinks as children of 'styled Navlink'...

import styled from 'styled-components';

export const NavItem = styled.div` // just style a div here... (or section etc...)
  display: flex;
  justify-content: space-around; // this should give you an equal emaout of space between the links... 
  align-items: center; 
`;
SakoBu
  • 3,972
  • 1
  • 16
  • 33