Reactjs 遗留上下文API与React路由器dom进行反应

Reactjs 遗留上下文API与React路由器dom进行反应,reactjs,react-router,react-router-dom,context-api,Reactjs,React Router,React Router Dom,Context Api,我正在使用react+react路由器dom。我的代码在控制台中显示此消息 The old API will be supported in all 16.x releases, but applications using it should migrate to the new version. Please update the following components: Consumer, Provider Learn more about this warning here: h

我正在使用react+react路由器dom。我的代码在控制台中显示此消息


The old API will be supported in all 16.x releases, but applications using it should migrate to the new version.

Please update the following components: Consumer, Provider

Learn more about this warning here: https://reactjs.org/link/legacy-context
    at Provider (http://localhost:3000/static/js/0.chunk.js:2330:26)
    at Router (http://localhost:3000/static/js/0.chunk.js:4062:30)
    at BrowserRouter (http://localhost:3000/static/js/0.chunk.js:3682:35)
    at div
    at App
我只使用了2个文件(我更改或添加的)

从“React”导入React
从“react Router dom”导入{BrowserRouter as Router}
从“/Routers”导入{Routers}
导出默认函数App(){
返回(
);
}
和路由器文件

import React from "react";

import { Switch, Route } from "react-router-dom";

export const Routers = () => {
    return (
        <Switch>
            <Route exact path="/main">
                <h1>hello</h1>
            </Route>
        </Switch>
    )
}
从“React”导入React;
从“react router dom”导入{Switch,Route};
导出常量路由器=()=>{
返回(
你好
)
}

这意味着,哪个库有旧版本或者我可以解决这个问题?

您在
包中指定了什么版本的
react router dom
。json
?哦,我把不同的包混在一起了。js服务器和客户端。现在一切似乎都安装正确,它的工作。版本是“react router dom”:“^5.2.0”,您在
包中指定了什么版本的
react router dom
。json
?哦,我把不同的包混在了一起。js服务器和客户端。现在一切似乎都安装正确,它的工作。版本为“^5.2.0”,
import React from "react";

import { Switch, Route } from "react-router-dom";

export const Routers = () => {
    return (
        <Switch>
            <Route exact path="/main">
                <h1>hello</h1>
            </Route>
        </Switch>
    )
}