Emr*_*ğan 9 reactjs react-router remix.run
我想将react-router
包升级到v6
. 它对包有依赖性history
,在history
包路线图中,文档说history.length
很快就会被弃用甚至删除。你可以看一下https://github.com/remix-run/history/issues/689
我想知道在将包升级到最新版本时是否有其他替代方案可以history.length
在我的代码中使用。react-router
举个例子,我的用法之一:
import { useHistory } from 'react-router';
const history = useHistory();
const onGoBack = () => {
if (history.length > 2) {
history.goBack();
} else {
history.push('/portfolio');
}
};
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1296 次 |
最近记录: |