Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

useLinkClickHandler

// React Router v6:
// hook returns a click event handler to for navigation when
// building custom <Link>
import { useHref, useLinkClickHandler } from 'react-router-dom'

const StyledLink = styled('a', { color: 'fuchsia' })

const Link = React.forwardRef(
  (
    { onClick, replace: false, state, target, to, ...rest }, ref
  ) => {
    let href = useHref(to)
    let handleClick = useLinkClickHandler(to, {
      replace,
      state,
      target
    })

    return (
      <StyledLink
        {...rest}
        href={href}
        onClick={e => {
          onClick?.(e)
          !e.defaultPrevented && handleClick(e)
        }}
        ref={ref}
        target={target}
      />
    )
  }
)
Comment

PREVIOUS NEXT
Code Example
Javascript :: The slice reducer for key "books" returned undefined during initia 
Javascript :: kube allow pod deployment on master node 
Javascript :: Get javascript object from array by filter 
Javascript :: on click a button triger a tab bootstrap 5 
Javascript :: how to send varible to another page in nuxt.js 
Javascript :: template.json exlude files from generating 
Javascript :: how to make console log hello in discord.js 
Javascript :: if else condition in angular if user enter string value in input integer 
Javascript :: javascript random number between 10 and 100 
Javascript :: angular assign class invalid form 
Javascript :: comment creer des switch en react js 
Javascript :: JavaScript call url many times 
Javascript :: take money from user and give change as output using javascript 
Javascript :: nodejs Websocket chat room 
Javascript :: implict type coercion in js 
Javascript :: Finding the longest word in a string 
Javascript :: javascript get element by class domlist undefined 
Javascript :: material ui paper color default background 
Javascript :: jquery datatable dropdown from stored procedure values 
Javascript :: js wrap a function pass parameters to function 
Javascript :: show capture of createCapture p5 js 
Javascript :: jit and aot 
Javascript :: serverless web app with react netlify 
Javascript :: js uid from 8 characters or digits 
Javascript :: Constant declaration in ES6 
Javascript :: format file using jq input curl 
Javascript :: Write File to the Operating System with NodeJS 
Javascript :: elementor slider javascript edit 
Javascript :: react redux open another page 
Javascript :: promise.all to send emails 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =