R
R
Ruslan Absalyamov2018-03-04 22:19:45
React
Ruslan Absalyamov, 2018-03-04 22:19:45

How can I make a transition to another page through Link?

I can't go to another page, so that the page is not below the Auth component, but opens as it opens to the entire spherical and window height
My implementation

import React, { Component } from "react";
import ReactDOM from "react-dom";
import { BrowserRouter, Route, Switch } from "react-router-dom";
import Auth from "./Auth";
import Registration from "./Registration";

export default class Router extends Component {
  render() {
    return (
      <BrowserRouter>
        <div>
          <Switch>
            <Route path="/login" component={Auth} />
            <Route path="/registration" component={Registration} />
          </Switch>
        </div>
      </BrowserRouter>
    );
  }
}

ReactDOM.render(<Router />, document.getElementById("root"));

Here is an example https://codesandbox.io/s/03r78ljrj0

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-03-04
@rusline18

Why are you wrapping the link in a router? Fix:

<BrowserRouter>
  <Link to="/registration">Зарегестрироваться</Link>
</BrowserRouter>

On the:
<Link to="/registration">Зарегестрироваться</Link>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question