Having trouble removing lines from Router Link? Unfortunately, using style={{'textDecoration': 'none'}} doesn't seem to be doing the trick

Does anyone know why the text decoration is not working on my link when I use text-decoration none? Any solutions or suggestions would be greatly appreciated. Thank you in advance! Navbar.js file

import React,{useState} from "react";
import { makeStyles } from "@material-ui/core/styles";
import {AppBar, Toolbar, Tab, Tabs, IconButton, Menu, MenuItem, useMediaQuery, useTheme, Button} from "@material-ui/core";
import MenuIcon from "@material-ui/icons/Menu";

import { Link } from "react-router-dom";

import {navlinks} from './navbarlinks';
import {FaFacebook} from 'react-icons/fa';
import {FaInstagram} from 'react-icons/fa';
import {FaLinkedinIn} from 'react-icons/fa';
import {FaTwitter} from 'react-icons/fa';

const useStyles = makeStyles((theme) => ({
  root: {
    flexGrow: 1
  },
  menuButton: {
    marginRight: theme.spacing(2)
  },
  tab : {
    color : '#000000',
    'textDecoration': 'none'       
  },
  appBarTransparent: {
    backgroundColor: 'rgba(255,255,255,0.1);'
  },
  appBarSolid:{

  }
}));

const Navbar = () => {
  const classes = useStyles();
  const [anchorEl, setAnchorEl] = React.useState(null);
  const [anchorE2, setAnchorE2] = React.useState(null);
  const open = Boolean(anchorEl);  

  const [value,setValue] = useState(0);

  const handleMenu = (event) => {
    setAnchorEl(event.currentTarget);
  };

  const handleOpenMenu = e => {
    setAnchorE2(e.currentTarget);
  }

  const handleMenuClose = e => {
    setAnchorE2(null);
  }

  const handleClose = () => {
    setAnchorEl(null);
  };

  function a11yProps(index) {
    return {
      id: `simple-tab-${index}`,
      'aria-controls': `simple-tabpanel-${index}`,
    };
  }

  const handleClickTab = (e, newValue) => {
    setValue(newValue);
  }

  const theme = useTheme();

  const isMatch = useMediaQuery(theme.breakpoints.down('sm') );  

  return (
    <div>
      <AppBar position="sticky" className={classes.appBarTransparent}>
        <Toolbar>
          <Link to='/'><img src="/images/image2vector.svg" alt='logo' style={{'border-radius' : '33%', 'maxHeight' : 'auto', 'maxWidth':'112px'}}/></Link>
          { !isMatch ? 
                    <div className={classes.root}>
                        <Tabs   onChange={handleClickTab} indicatorColor='secondary' value={value} aria-label="icon tabs example">
                            {
                                navlinks.map( link => {
                                return <Link to={link.to}><Tab className={classes.tab} style={{'textDecoration': 'none'}}label={link.title} {...a11yProps(link.id)} /></Link>
                                })                                              
                            }                                                       
                        </Tabs>                         
                    </div> 
                    : 
                    <div className={classes.root}>
                        <IconButton
                          aria-label="account of current user"
                          aria-controls="menu-appbar"
                          aria-haspopup="true"
                          onClick={handleMenu}
                          color="inherit"
                        >
                          <MenuIcon />
                        </IconButton>
                        <Menu
                          id="menu-appbar"
                          anchorEl={anchorEl}
                          anchorOrigin={{
                            vertical: "top",
                            horizontal: "right"
                          }}
                          keepMounted
                          transformOrigin={{
                            vertical: "top",
                            horizontal: "right"
                          }}
                          open={open}
                          onClose={handleClose}
                          disableRipple
                        >
                            { navlinks.map(link => {
                                return <MenuItem onClick={handleClose}><Link to={link.to}>{link.title}</Link></MenuItem>
                                })
                            }              
                        </Menu>
                          
                    </div>                                                                         
            }
            <div>
              <Button               
                color="secondary" 
                onClick={handleOpenMenu}
                aria-controls='menu'
              >
                Contact Us
              </Button>
            </div>
            <Menu
              id='menu'
              anchorE2={anchorE2}
              open={Boolean(anchorE2)}
              onClose={handleMenuClose}
              anchorOrigin={{
                vertical: "bottom",
                horizontal: "right"
              }}
              keepMounted
              transformOrigin={{
                vertical: "top",
                horizontal: "center"
              }}
            > <MenuItem>+91 9426231824</MenuItem>             
              <MenuItem><FaFacebook /></MenuItem>
              <MenuItem><FaInstagram /></MenuItem>
              <MenuItem><FaLinkedinIn /></MenuItem>
              <MenuItem><FaTwitter /></MenuItem>              
            </Menu>
        </Toolbar>
      </AppBar>
    </div>
  );
};
export default Navbar;

navbarlink.js

export const navlinks = [
    {
        title: 'Home',
        to : '/',
        id:0
    },
    {
        title: 'About US',
        to : '/aboutus',
        id:1
    },
    {
        title: 'Projects',
        to : '/projects',
        id:2
    },
    {
        title: 'Services',
        to : '/services',
        id:3
    },
    {
        title: 'Get A Quote',
        to : '/contactus',
        id:4
    }
]

Why is text-decorating none not applied to my links in the app? Any insights are welcome, thank you in advance!

Answer №1

My solution involved utilizing styled-components and incorporating the code snippet below

const StyledLink = styled(Link) `
  text-decoration: none;

  &:focus, &:hover, &:visited, &:link, &:active {
      text-decoration: none;
`;

Answer №2

Get rid of the quotation marks around 'textDecoration'

Replace this particular line:

return <Link to={link.to}><Tab className={classes.tab} style={{'textDecoration': 'none'}}label={link.title} {...a11yProps(link.id)} /></Link>

with this one:

return <Link to={link.to}><Tab className={classes.tab} style={{textDecoration: 'none'}}label={link.title} {...a11yProps(link.id)} /></Link>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unable to properly label or identify the DatePicker component for Yup validation

I've encountered an issue with my Formik form that utilizes Yup for validation. I'm having trouble integrating a Datepicker field into the yup validation process. Here's the code where everything renders correctly, but when I try to nest &l ...

The MaterialTable is unable to display any data

After calling the fetch function in the useEffect, my getUsers function does not populate the data variable. I am unable to see rows of data in the MaterialTable as the data structure is in columns. I need help figuring out what I'm doing wrong. func ...

What is the correct way to utilize window.scrollY effectively in my code?

Is it possible to have a fixed header that only appears when the user scrolls up, instead of being fixed at the top by default? I've tried using the "fixed" property but it ends up blocking the white stick at the top. Adjusting the z-index doesn&apos ...

Interact with webpage dropdown menus using Python

I'm currently working on a Python script that interacts with a webpage, specifically , to retrieve a (DNA sequence in fasta format) file. The file is automatically downloaded when a user clicks on a dropdown menu. Here's the dropdown menu: Dow ...

Styling text on a HTML webpage

Is there a way to center text in the caption and add a link on the far-right of the caption? Let me know if this is possible. The format for the caption should be: Centered Text Right-justified link ...

Leveraging UseParams for Detailed Product Pages

I am in the process of developing a product detail page using the useParams Hook in my ReactJS application. Unfortunately, I have encountered some issues as I am able to retrieve the ID from the URL but unable to fetch the item's title, image, and pri ...

Need Some Help Reversing the Direction of This CSS Mount Animation?

Exploring this fiddle, I encountered a small div showcasing an opacity animation. The animation smoothly executes when the state transitions to true upon mounting the component, causing the div to fade in beautifully. However, I faced a challenge as the an ...

External vendor scripts such as JavaScript and jQuery are not functioning properly after being rendered in a ReactJS environment

I am currently developing a frontend web app using ReactJS. I obtained a template from W3layout that is built with HTML5, CSS3, and custom JS files, along with various third-party/vendor plugins like nice-select, bootstrap, slik, owl-carousel, etc. Despit ...

NPM: There are no valid TypeScript file rules specified

Currently working on a small project using React.JS. Whenever I execute : npm run start, the following message gets logged: Starting type checking and linting service... Using 1 worker with 2048MB memory limit Watching: /Users/John/Projects/myProject/src ...

Centering an image that is absolutely positioned within a container that is relatively positioned, horizontally

Looking to center an image that is positioned absolutely horizontally within a container that is relatively positioned. After attempting with CSS and not finding success, I ended up using Jquery. http://jsfiddle.net/CY6TP/ [This is my attempt using Jquery ...

Secure verification is a critical element within the core component of React JS

Creating a user-based application using Meteor (v1.3) requires strong authentication and authorization mechanisms. I found an insightful example by the author of Flow Router that delves into setting up authentication and authorization using Flow Router. h ...

Connecting an onclick event to trigger an external file

I have a scenario where I need to link an array of buttons with respective mp3 files. For example, if button number 5 is clicked, the 5th mp3 file should be played. How can I modify the code below to achieve this functionality? Any examples or suggestions ...

Clearing values in a Redux form

I am using Redux to toggle the visibility of components based on a value. I want to reset values when switching between options. How can I clear state values when switching between fields that are being hidden or shown? What is the best approach for vali ...

What is the best way to eliminate gridlines or borders in a React-Data-Grid component?

Is there a way to remove gridlines from a simple table? You can view the code in this codesandbox demo: https://codesandbox.io/s/rdg-cell-editing-u2ood. I'm wondering if I need to manually override internal CSS classes or if there's a specific p ...

Is it possible to optimize the memory usage when running `next build`?

My Next.js app is hosted on a 1gb memory server. However, whenever I run next build to redeploy my application, the memory usage spikes from around 70% to 100%, causing the system to slow down significantly. The build process usually takes 15-20 minutes un ...

Conceal or style the filter panel in a DT datatable

Here is an example to consider: library(DT) L <- 10 datatable( data.frame( var1 = sapply(1:L, function(x) paste("<X>",paste0(x, letters, LETTERS, "\n", ...

In search of a resolution for the error message "multipart: NextPart: bufio: buffer full" while attempting to upload an image via a fetch post request. Can anyone provide guidance

What steps can be taken to resolve the issue "multipart: NextPart: bufio: buffer full" when using a fetch post request to upload an image? I have a feature on my website that allows users to upload profile pictures. I use a fetch post request for this pur ...

When hovering over individual links within a set of blocks, ensure that the other links are not affected or disrupted

I need help creating a forum category link guide. Similar to this example... Specifically, I want it to display as Forums > The Financial Roadmap Two issues I am facing are: when hovering over the link, it shifts down one row and how can I add blocks lik ...

Guide to implementing onClick event on options within Autocomplete Component(Material UI)

I have been trying to figure out how to add an onClick event to the options in my autocomplete search functionality. I want the selected option to redirect somewhere when clicked, rather than just populating a search field or text box. Despite searching ...

Is there a way for me to convert my (TypeScript Definition) .d.ts file into a (JavaScript) .js file?

It seems that there are plenty of guides available on converting a file from .js to .d.ts, but not the other way around. Specifically, I have some code in .d.ts format and I would like to convert it into JavaScript. Can anyone offer assistance with this t ...