只有在刷新页面后,React-router-dom才会在更改链接后不呈现组件

时间:2020-04-12 22:13:56

标签: javascript reactjs react-router react-router-dom

我的React版本是:16.13.1,而我的LookAtWorldX=(Camera.x)+(Vector.x*Depth); 版本是:5.1.2。

仅当我刷新页面时组件才会更新,只有链接会更改,但组件不会呈现。

React-router-dom

链接代码以更改路线:

import React from "react";
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";

import Todo from "./components/Todo/Todo";
import About from "./components/About/About";

const Routes = () => (
    <Router>
        <Switch>
            <Route exact path='/' component={Todo}/>
            <Route path="/about" component={About}/>
        </Switch>
    </Router>
);

export default Routes;

0 个答案:

没有答案