Answer the question
In order to leave comments, you need to log in
Preact/React how to implement links without displaying the href attribute?
Hello!
Perhaps I haven’t studied React too well and don’t know everything, but even armed with Google, github and various resources, I couldn’t understand how to implement this:
There is a curious.ru mail project made using PReact
And there is a menu of three links. Only now they are divs and do not have an href attribute:
<nav class="_1XOC9SnsacmiKGPjY05_Ib _3JGVJkMDUWDI2QgLrC1_2u">
<div class="_2bR2iQn7qZOC2HQhzPMjGr">Истории</div>
<div class="_2bR2iQn7qZOC2HQhzPMjGr">Билборд</div>
<div class="_2bR2iQn7qZOC2HQhzPMjGr">Избранное</div>
</nav>
Answer the question
In order to leave comments, you need to log in
Through history:
import React from "react";
import { withRouter } from "react-router-dom";
const Nav = ({ history }) => (
<nav>
<div onClick={() => history.push('/')}>Истории</div>
<div onClick={() => history.push('/bilboard')}>Билборд</div>
<div onClick={() => history.push('/loved')}>Избранное</div>
</nav>
)
export default withRouter(Nav);
import { Link } from "react-router-dom";
const Nav = () => (
<nav>
<Link to="/">Истории</Link>
<Link to="/bilboard">Билборд</Link>
<Link to="/loved">Избранное</Link>
</nav>
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question