cybel
cybel

Reputation: 391

Using react-router with an href button

I just started with reactjs and I don't quite seem to understand how to use it with buttons. So I got these two buttons here

  <a className="button is-warning">
  Sign up
  </a>

  <a className="button is-warning">
  Login
  </a>

And I want them to link to

<Route path="/account" component={Account}/>
<Route path="/start" component={Start}/>

I know there are already quite a few questions and answers about this topic here and I also watched tutorials and try to figure it out, but still I can't seem to get into my head how to do it.

Upvotes: 0

Views: 1175

Answers (2)

hrmdev
hrmdev

Reputation: 13

I also tried to use the component but that was throwing some error (don't remember which errors) but then I just tried to use the from react-router-dom and it worked like a charm.

Upvotes: 0

Win
Win

Reputation: 2133

Use <Link> instead of <a>

<Link to="/account" className="button is-warning">Sign up</Link>
<Link to="/start" className="button is-warning">Login</Link>

Upvotes: 2

Related Questions