“Link in React” Code-Antworten

Link in React

import {Link} from 'react-router-dom'
<Link to="/">Home</Link>
<Link to="about">About</Link>
Shirshak kandel

Link React

//Go to link and refresh the page
<a onClick={() => {window.location.href="/something"}}>Something</a>
Zarden

Link Tag React

<Link to={`/users/${user.id}`} activeClassName="active">{user.name}</Link>
// becomes one of these depending on your History and if the route is
// active
<a href="/users/123" class="active">Michael</a>
<a href="#/users/123">Michael</a>

// change the activeClassName
<Link to={`/users/${user.id}`} activeClassName="current">{user.name}</Link>

// change style when link is active
<Link to="/users" style={{color: 'white'}} activeStyle={{color: 'red'}}>Users</Link>
2 Programmers 1 Bug

Ähnliche Antworten wie “Link in React”

Fragen ähnlich wie “Link in React”

Weitere verwandte Antworten zu “Link in React” auf TypeScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen