Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

next router push

import { useRouter } from 'next/router'

function ActiveLink({ children, href }) {
  const router = useRouter()
  const style = {
    marginRight: 10,
    color: router.asPath === href ? 'red' : 'black',
  }

  const handleClick = (e) => {
    e.preventDefault()
    router.push(href)
  }

  return (
    <a href={href} onClick={handleClick} style={style}>
      {children}
    </a>
  )
}

export default ActiveLink
Comment

router.push next js

 router.push(href)
Comment

PREVIOUS NEXT
Code Example
Javascript :: create slug in express 
Javascript :: vue nexttick 
Javascript :: regular expression javascript 
Javascript :: append array to array javascript 
Javascript :: vuejs pass data to router-view 
Javascript :: creating room in ws nodejs 
Javascript :: pass object in asyncstorage in react native 
Javascript :: js addeventlistener input search phone 
Javascript :: javascript convert string to bool 
Javascript :: palindrome string js 
Javascript :: get field type file js and loop 
Javascript :: js add props to obj conditionally 
Javascript :: javascript get elements by multiple class names 
Javascript :: what is angularjs 
Javascript :: jquery limit words in string 
Javascript :: nestjs AXIOS_INSTANCE_TOKEN 
Javascript :: lexical environment in javascript 
Javascript :: how to inspect element attributes in cypress 
Javascript :: hook use effect with hooks 
Javascript :: javascript match 
Javascript :: adding cors parameters to extjs ajax 
Javascript :: jquery on method 
Javascript :: event delegation javascript 
Javascript :: angular generate validator 
Javascript :: batch mkdir 
Javascript :: run node app locally 
Javascript :: js how to filter range imutable array 
Javascript :: look behind regex 
Javascript :: material ui change icon size on xs screen 
Javascript :: jquery scroll to element toggle menu item 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =