react-router 重定向 vs history.push [英] react-router Redirect vs history.push

查看:52
本文介绍了react-router 重定向 vs history.push的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读 react-router-redux例子,我很困惑,有什么区别:

I was reading react-router-redux examples and I confused, what is the difference beetween:

import { Redirect } from 'react-router-dom'

...

<Redirect to='/login' /> 

import { push } from 'react-router-redux'

...

push('/login')

推荐答案

重定向

渲染 将导航到新位置.新位置将覆盖历史堆栈中的当前位置,就像服务器端重定向(HTTP 3xx)一样.

Rendering a <Redirect> will navigate to a new location. The new location will override the current location in the history stack, like server-side redirects (HTTP 3xx) do.

历史

push 函数 将新条目推入历史堆栈

这篇关于react-router 重定向 vs history.push的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆