React Router 6版本使用感受如何?
- 内容介绍
- 文章标签
- 相关推荐
本文共计2553个文字,预计阅读时间需要11分钟。
最近使用了react-router v6版本,感觉改动很大,记录一下。
React Router v6大量使用了React hooks,所以在尝试升级到v6之前,需要确保你的React版本是16.8或更高。这带来了很多好处。
最近使用了一下react-router@6 版本感觉有很大的改动,记录一下。
React Router v6 makes heavy use of React hooks, so you'll need to be on React 16.8 or greater before attempting the upgrade to React Router v6. The good news is that React Router v5 is compatible with React >= 15, so if you're on v5 (or v4) you should be able to upgrade React without touching any of your router code.
官网给出的原文上面说的很清楚了,在 6 版本上使用了React Hooks写法,说明不支持class类来写。并且要求react版本在16.8以上。如果想兼容class组件 以及 react@15使用只能用react-router@5版本。
本文共计2553个文字,预计阅读时间需要11分钟。
最近使用了react-router v6版本,感觉改动很大,记录一下。
React Router v6大量使用了React hooks,所以在尝试升级到v6之前,需要确保你的React版本是16.8或更高。这带来了很多好处。
最近使用了一下react-router@6 版本感觉有很大的改动,记录一下。
React Router v6 makes heavy use of React hooks, so you'll need to be on React 16.8 or greater before attempting the upgrade to React Router v6. The good news is that React Router v5 is compatible with React >= 15, so if you're on v5 (or v4) you should be able to upgrade React without touching any of your router code.
官网给出的原文上面说的很清楚了,在 6 版本上使用了React Hooks写法,说明不支持class类来写。并且要求react版本在16.8以上。如果想兼容class组件 以及 react@15使用只能用react-router@5版本。

