score:0
there is actually a property of activeclassname in navlink
of react router.
it goes like this
import { navlink } from 'react-router-dom`
...
<navlink exact activeclassname="your_active_css_classname" classname="normal_css">link name </navlink>
don't forget to add exact. read more here: https://reacttraining.com/react-router/web/api/navlink
score:0
light/fast way to do this would be to change the class at the parent dom element of these <link>
elements... from there the css would do what it works best.
assuming these <link> ... </link>
tags are enclosed inside a <nav> ... </nav>
tag, which is the parent dom element.
{ (onthepage) ? <nav classname="onthepageclass"> ... </nav> : <nav classname="normalclass"> ... </nav> }
try this else share mvce if you get stuck so that it serves as a good example for others looking for help
Source: stackoverflow.com
Related Query
- How do you set an 'active' class in React and CSS?
- How to set active link in Navbar using Nav.Link and React Router?
- How to make the pass a dynamic value to css class and cusmize in material UI in react
- I am trying to animate an object with css in react and change the animation (timing) dynamically, how can I set the style after animation end?
- How to set a dynamic class in react js and retrieve it in Jquery
- How to set active class on anchor links using react
- How can you use CSS modules together with Typescript, React and Webpack?
- React Native Navigation, how do you pass and use Props between Class Components?
- How do you set an active state on one component at a time, and remove the active state on all others in React?
- How to style the active link childs using CSS in JS and React Router?
- How to set active class in react render method?
- How to add CSS new 'content-visibility' property to a React class component that uses Typescript and SCSS?
- How do you remove a CSS class from a certain element of a list with React
- How do you correctly add a CSS class to a react component (with broken example)?
- How to test the style inside the CSS class for React component using Jest and Enzyme?
- How do you get a fade-in transition while using React useState hook to change class instead of CSS className:hover?
- How to define css variables in style attribute in React and typescript
- How to set image width to be 100% and height to be auto in react native?
- How to import CSS modules with Typescript, React and Webpack
- Set loading state before and after an action in a React class component
- How to set up Babel 6 stage 0 with React and Webpack
- How to apply CSS and Styling to a React component
- How do you center a div element in react w/out external css file
- How to set React component state and props from browser
- React Native: How to set <TextInput/>'s height and width to <View/> container?
- How can you set path of match with MemoryRouter and Jest? (not location or history)
- ReactJS - How to change style and class of react component?
- Conditionally set active class on menu using react router current route
- How to use vw and vh css with React Native
- How do you set the Typescript type for useRef hook in React Native?
More Query from same tag
- is it possible to anchor-scrolling inside a scrolled div?
- Why do I get undefined when mapping and passing through a prop (ReactJS)
- How to find the given image source (url) is in svg format?
- Momentum for wheel event is cancelled when child element is removed
- How to get a counter on specific values on JSON file with JS?
- SCRIPT438: Object doesn't support property or method 'assign'
- ReactJS onclick of a button display mongo collection in table format
- event is null when using isClearable on react-select
- Recharts line chart cut off top line
- Typescript passing component or DOM tag name
- How to search and find table details using ant design auto complete(react js)
- Is there a way to avoid infinite loop of dependencies and to pass the correct dependencies to useEffect hook in this case?
- Not able to set the max height of React bootstrap table
- How to pass a number as a prop to a styled component?
- How to do an "ellipsis" like effect for non string elements and restrict rows up to 2?
- React 16.14.0: Error was not caught ReferenceError: exports is not defined
- How to search colors when colors are stored as hexadecimal or RGB value?
- How to force App to re-render after mutation?
- How to change the state with React TypeScript 2.0?
- Fetched value from axios as initial value of another state - React Hooks
- Video pausing unexpectedly when video `onTimeUpdate` event is called (with React Hooks)
- How can I prevent refreshing HTML Video element (iFrame as well) on React State Update?
- Getting Project Version from Node / package.json in Jenkins
- Trying to render a new instance in ReactJS
- I need to re render state and make onChange operator work on input element
- React/JestJS/Enzyme: How to test for ref function?
- Conditionally render empty div or error with React & Bootstrap
- Generator function inside useCallback is returning same values in react, How to solve this?
- Make custom url /myadmin for mounting and using react-admin app
- Handle Redux-form events