qiqiboy / react-animated-router

Dynamic transitions with react-router(v6) and react-transition-group
57 stars 17 forks source link

升级到react router5,会报 You should not use <withRouter(AnimatedRouter) /> outside a <Router> #5

Closed kandykim closed 4 years ago

kandykim commented 4 years ago

需要把import { withRouter } from 'react-router' 更改为import { withRouter } from 'react-router-dom'后不报错了。

qiqiboy commented 4 years ago

react-router v4和v5的npm发布的代码方式有较大变动。清空node_modules,重新安装就可以。

kandykim commented 4 years ago

清空重新安装后依然报错,现在使用框架是webpack4.41 + react16.11.0 + babel7 + react-router5.1.2

qiqiboy commented 4 years ago

清空重新安装后依然报错,现在使用框架是webpack4.41 + react16.11.0 + babel7 + react-router5.1.2

可以 open node_modules/react-router open node_modules/react-router-dom看下是否都是5.x版本,这个要保持一致。这个错误就是因为安装了非同样major版本的包,导致使用的createContext对象不一致,导致react context无效

kandykim commented 4 years ago

确认了都是5.1.2。最后重新clone了项目install了一下才不报错的